我正在寻找一种方法,只有当同一工作表上的另一个单元格不为空时,才能在特定的Target.Address上触发SelectionChange事件。 我正在使用的代码就是这个:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("K20:M20").Address Then _
RequestorNameEmpty
Sub RequestorNameEmpty()
If ActiveSheet.Range("D20:H20").Value = "" Then
MsgBox ("Enter your name first! ")
GoTo ExitSub
Else
ActiveSheet.Range("K20:M20").Value = ActiveSheet.Range("C3").Value
End If
ExitSub
Exit Sub
End Sub
谢谢
答案 0 :(得分:2)
试试这个
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("K20:M20").Address Then RequestorNameEmpty
End Sub
Sub RequestorNameEmpty()
If Range("D20").Value = "" Then
MsgBox ("Enter your name first! ")
Exit Sub
Else
Range("K20").Value = Range("C3").Value
End If
End Sub