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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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,215,035
Messages
6,122,791
Members
449,095
Latest member
m_smith_solihull

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