activate macro only in sheet2

O

Otto Moehrbach

I don't know how you want to activate the macro, but if you want it to work
only on Sheet2, use a line something like:
If ActiveSheet.Name<>"Sheet2" Then Exit Sub
If you want it to work with only Sheet2 whether or not it is the active
sheet use something like:
With Sheets("Sheet2")
'Your code goes here
End With
HTH Otto
 
R

Richard Buttrey

How do I activte a macro only for sheet2?

If Sheet2 is the Active Sheet when the macro runs, then wrap your
macro code in an IF..Then test

If ActiveSheet.Name="Sheet2 Then
YourCode...
End If

If you are looping through various sheets without them becoming
active, then the same logic applies, just test for the sheet name at
the start of your code.


HTH
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 
Top