在excel单元中输入“是”,内容变成1,如何实现?

来源:百度知道 编辑:UC知道 时间:2024/05/21 21:14:39
我希望实现如下效果:
在A列,输入“是”,内容实际变成了1,输入否,变成2
在B列,输入“北京”,内容实际变成了1,输入上海,变成2
在C…………………………

谢谢
smallcolour 大哥,辛苦您了.谢谢.
批量粘贴虽然不会出错了,但是批量粘贴后内容没有按要求转换.
粘贴的是什么内容,结果还是什么内容.

再试试吧

Private Sub Worksheet_Change(ByVal Target As Range)
b = Target.Column
If Target.Rows.Count > 1 Then
For Each x In Selection
a = ActiveCell.Value
Select Case b
Case 1
If a = "是" Then
ActiveCell.Value = 1
Else
If a = "否" Then
ActiveCell.Value = 2
Else
If a = 1 Then
ActiveCell.Value = 1
Else
If a = 2 Then
ActiveCell.Value = 2
Else
MsgBox "你输入的不是是与否"
End If
End If
End If
End If
Case 2
If a = "北京" Then
Target.Value = 1
End If
If a = "上海" Then
Target.Value = 2
End If
Case 3
If a = "本科" Then
Target.Value = 1
End If
If a = "研究生" Then
Target.Value = 2
End If
End Select
ActiveCell.Offset(1, 0).Select
Next
Exit Sub
End If
a = Target.Value
Select Case b
Case 1
Select Case a
Ca