Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$13" Then
Select Case Target.Value
Case "上海": [G38] = 1: [G51] = 1: [G55] = 1
Case "北京": [G38] = 2: [G51] = 2: [G55] = 2
Case "天津": [G38] = 3: [G51] = 3: [G55] = 3
Case "武汉": [G38] = 27: [G51] = 27: [G55] = 27
End Select
End If
End Sub
详见附件,修改起来应该不复杂吧!
你只讲了上海,没有说其他,这里以上海为例,你可以加上其他的。如果有数据可以引用,直接引用即可。这里是直接赋值
代码如下(单元格事件)
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$G$13" Then Exit Sub '不是G13单元格,退出程序
If Target.Value = "上海" Then
[G38] = 1
[G51] = 1
[G55] = 1
End If
End Sub