Sub Test()
If ActiveSheet.name<>"A001" Then Exit Sub
Msgbox "Hello world! The active worksheet is named A001!"
End sub
Thanks SaurabhjThanks for the feedback alz.
ThanksIf you want a code to run only if active worksheet name is "A001" then try:
If you want to run when A001 is activated then use the code above.
VBA Code:Sub Test() If ActiveSheet.name<>"A001" Then Exit Sub Msgbox "Hello world! The active worksheet is named A001!" End sub