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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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
 
Upvote 0

Forum statistics

Threads
1,218,742
Messages
6,144,220
Members
450,531
Latest member
avril18

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
Back
Top