Home |
Search |
Today's Posts |
#1
|
|||
|
|||
select worksheet and run macro
Hi,
I am trying to run some code when a worksheet is selected. I'm doing this using a macro currently (code below), but this requires that i use a quick menu button and i would like to make it a form button and assign a macro to it (so i can distribute the file without everyone having to create a menu button). I would like to replace (or modify) the code below to select any sheet other than the ones named "a" and "b". Can someone help modify this code please ? Many thanks, Code:
Sub ImportAlarms() Dim thisSheet As Worksheet Dim targetSheet As Worksheet On Error GoTo failed Set thisSheet = Application.ActiveSheet Set targetSheet = Sheets(TARGET_SHEET) If (Not (thisSheet Is Nothing) And Not (targetSheet Is Nothing) And thisSheet.Name < targetSheet.Name) Then If (thisSheet.Cells(1, 1) = "Profile Alarms") Then Call importSheet(thisSheet) Else Call MsgBox("Please select an Alarm sheet") End If Else Call MsgBox("Please select an Alarm sheet") End If Exit Sub failed: Call MsgBox("Please select an Alarm sheet") End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select Worksheet to print Macro | Excel Worksheet Functions | |||
why does this macro select the entire worksheet when run? | Excel Discussion (Misc queries) | |||
need a macro select all cells in a worksheet? | Excel Discussion (Misc queries) | |||
select worksheet to run macro | Excel Discussion (Misc queries) | |||
Help Please! Macro Error on Select Worksheet | Excel Programming |