我知道单张工作表不能有两个名为工作表更改的独立子工作表。所以我删除了它。
我无法弄清楚运行此代码所需的修改。会爱一些帮助。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 10 And Target.Column = 121 And Target.Count = 1 Then
Set Target = Range("range1")
If Target <> "Calculate" Then Exit Sub
Select Case Target.Value
Case "Calculate"
macro1
End Select
End If
ElseIf Target.Row = 10 And Target.Column = 123 And Target.Count = 1 Then
Set Target = Range("range2")
If Target <> "Calculate" Then Exit Sub
Select Case Target.Value
Case "Calculate"
macro2
End Select
End If
End If
End Sub
答案 0 :(得分:1)
这样的事情对你有用。请注意,永远不要尝试重新分配Target
参数:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCheck1 As Range
Dim rngCheck2 As Range
Set rngCheck1 = Intersect(Target, Me.Range("DQ10")) 'Row 10, Column 121
Set rngCheck2 = Intersect(Target, Me.Range("DS10")) 'Row 10, Column 123
Application.EnableEvents = False
On Error GoTo CleanExit
If Not rngCheck1 Is Nothing Then
If Trim(LCase(rngCheck1.Value)) = "calculate" Then Call macro1
End If
If Not rngCheck2 Is Nothing Then
If Trim(LCase(rngCheck2.Value)) = "calculate" Then Call macro2
End If
CleanExit:
Application.EnableEvents = True
End Sub