Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select dynamic data in 2 columns, and repeat macro to next sheet | Excel Discussion (Misc queries) | |||
Macro to select cells without a certain value and select a menu it | Excel Worksheet Functions | |||
Macro to go to select sheet | Excel Discussion (Misc queries) | |||
macro sheet select | Excel Discussion (Misc queries) | |||
Macro, select Sheet "Number", NOT Sheet Name | Excel Worksheet Functions |