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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

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
 

Forum statistics

Threads
1,148,219
Messages
5,745,452
Members
423,952
Latest member
EduardoM

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