我正在寻找一种解决方案,可以将以下代码自动添加到工作簿中的特定工作表中:
Private Sub Worksheet_Change(ByVal Target As Range)
'this is to be inserted into the AllEvents (sheet2) module
'this code allows the data validation dropdown to function
If Target.CountLarge > 1 Then Exit Sub
If Target.Address <> "$A$1" Then Exit Sub
Application.EnableEvents = False
If Me.FilterMode Then Me.ShowAllData
Select Case Target.Value
Case "All Events"
Case "No Mains & Ends"
ActiveSheet.Range("$A$2:$O$1494").AutoFilter Field:=6, Criteria1:="<>Main and Ends"
Case "Sub Decisions"
ActiveSheet.Range("$A$2:$O$1494").AutoFilter Field:=4, Criteria1:="Subtitle"
End Select
Application.EnableEvents = True
End Sub
我不想从其他模块导入或复制。是否有方法选择特定的图纸模块并在VBE中编写此代码?
提前感谢您花时间阅读本文。
-B