Sub Worksheet_SelectionChange(ByVal ws As Range)
Dim rInt As Range
Dim rCell As Range
Set rInt = Intersect(Target, Range("B1:B32, B37:B45, K3:K11, K12:K18"))
If Not rInt Is Nothing Then
For Each rCell In rInt
rCell.Value = "1"
Next
End If
Set rInt = Nothing
Set rCell = Nothing
End Sub
答案 0 :(得分:3)
答案 1 :(得分:0)
您可以使用Workbook级事件(代码进入ThisWorkbook
模块)
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Const NOT_THIS_ONE As String = "Tester" '<< sheet to skip
Dim rInt As Range
Dim rCell As Range
If Sh.Name = NOT_THIS_ONE Then Exit Sub
Set rInt = Intersect(Target, Range("B1:B32, B37:B45, K3:K11, K12:K18"))
If Not rInt Is Nothing Then
For Each rCell In rInt
rCell.Value = "1"
Next
End If
Set rInt = Nothing
Set rCell = Nothing
End Sub