Sheet Name conditional

SignGuy

New Member
Joined
Jan 5, 2005
Messages
6
I use a number of different templates I open for various tasks... I want to run a macro that will exocute differently based on which template I am using at that time.

To simplify the question... I want a message box to pop up and say "Yea" if I am using a template named "Good Order1" and I want a message box to pop up and say "Boo" when I am using any other type of sheet.

I tried the following macro but still got "Boo" in my message box when I ran the macro:
If ActiveSheet.Name = "Good order1" Then MsgBox ("YEA") Else: MsgBox ("Boo")

Please advise!!
Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

parry

MrExcel MVP
Joined
Aug 20, 2002
Messages
3,355
Hi heres an example. Note if the workbook has been saved it will include the extension - Good Order1.xls

Code:
Sub SignGuy()
    If ActiveWorkbook.Name = "Good Order1.xls" Then
        MsgBox "Yea"
    Else
        MsgBox "Boo"
    End If
End Sub
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,589
Messages
5,765,314
Members
425,272
Latest member
Umba

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top