Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Narkom
 
Posts: n/a
Default activate macro only in sheet2


How do I activte a macro only for sheet2?


--
Narkom
------------------------------------------------------------------------
Narkom's Profile: http://www.excelforum.com/member.php...o&userid=32642
View this thread: http://www.excelforum.com/showthread...hreadid=524554

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Otto Moehrbach
 
Posts: n/a
Default activate macro only in sheet2

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
"Narkom" wrote in
message ...

How do I activte a macro only for sheet2?


--
Narkom
------------------------------------------------------------------------
Narkom's Profile:
http://www.excelforum.com/member.php...o&userid=32642
View this thread: http://www.excelforum.com/showthread...hreadid=524554



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Richard Buttrey
 
Posts: n/a
Default activate macro only in sheet2

On Mon, 20 Mar 2006 14:40:46 -0600, Narkom
wrote:


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
__________________________
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Narkom
 
Posts: n/a
Default activate macro only in sheet2


That was it!
Finally i got some light :)
Thank you both


--
Narkom
------------------------------------------------------------------------
Narkom's Profile: http://www.excelforum.com/member.php...o&userid=32642
View this thread: http://www.excelforum.com/showthread...hreadid=524554

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to auto activate macro when file opened bonzio Excel Worksheet Functions 3 December 17th 05 03:19 PM
How to auto activate macro when file open ? bonzio Excel Worksheet Functions 1 December 16th 05 02:45 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"