Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default On Sheet select Macro

Hi there

I need a macro to run, but only when a certain 'WorkSheet' is selected
from within a Workbook containing many worksheets.

Can anyone help me with this?
--
Colin G Eastwood
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default On Sheet select Macro

Use the "SheetActivate" event of the Workbook object.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Sheet2" Then
MsgBox "You selected Sheet2."
End If
End Sub

HTH.

-----Original Message-----
Hi there

I need a macro to run, but only when a

certain 'WorkSheet' is selected
from within a Workbook containing many worksheets.

Can anyone help me with this?
--
Colin G Eastwood
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default On Sheet select Macro

If you want to run the macro automatic when you select the sheet you can
use this event in the sheet module

Private Sub Worksheet_Activate()
MsgBox "Hi"
End Sub

Or use this line in your macro to exit the sub if the sheet you want
is not the active one

Sub test()
If ActiveSheet.Name < "yourname" Then Exit Sub
MsgBox "Your code"
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Colin G Eastwood" wrote in message ...
Hi there

I need a macro to run, but only when a certain 'WorkSheet' is selected
from within a Workbook containing many worksheets.

Can anyone help me with this?
--
Colin G Eastwood



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default On Sheet select Macro

Hi Brad

That did it!

Many thanks

Regards Colin



In article , Brad <anonymous@dis
cussions.microsoft.com writes
Use the "SheetActivate" event of the Workbook object.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Sheet2" Then
MsgBox "You selected Sheet2."
End If
End Sub

HTH.

-----Original Message-----
Hi there

I need a macro to run, but only when a

certain 'WorkSheet' is selected
from within a Workbook containing many worksheets.

Can anyone help me with this?
--
Colin G Eastwood
.


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
Select dynamic data in 2 columns, and repeat macro to next sheet Tasha Excel Discussion (Misc queries) 2 September 17th 09 07:00 PM
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Macro to go to select sheet Kevin Excel Discussion (Misc queries) 2 December 18th 07 02:28 AM
macro sheet select Dave K Excel Discussion (Misc queries) 2 October 21st 05 10:08 PM
Macro, select Sheet "Number", NOT Sheet Name DAA Excel Worksheet Functions 4 November 30th 04 05:29 PM


All times are GMT +1. The time now is 02:49 PM.

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"