Activesheet in Select Case Statement

bearcub

Well-known Member
Joined
May 18, 2005
Messages
734
Office Version
  1. 365
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
I want to use a series of message boxes to describe to the user how to use a sheet in a big file that I have (I have about 20 different sheets.


What I would like to do is set up a Select Case statement so that when the user pushes a button the appropriate set of instructions will pop up describing the purpose of the sheet. In stead of have 20 different macros for 20 buttons I would like to have one macro which will fire and be able to display the appropriate instructions based upon the active sheet name.

Is this possible?

Thank you in advance,

Michael
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Where exactly is this button going to reside?
 
Upvote 0
something like
Code:
Sub getsheetname()
    
        Select Case ActiveSheet.Name
            Case "Sheet1"
                MsgBox "Hello"
            Case "Sheet2"
                MsgBox "goodbye"
    End Select
 End Sub
 
Upvote 0
That's what I was looking for, the Select Case Activesheet.name. I was wasn't quite sure if that could be used as a criteria but I guess it can.

Thank you.

I'll attach the macro using this construct to a command button so when the user presses this button( I don't want it to pop up everytime the sheet is activated) they will get the information explaining the purpose of the of spreadsheet and how to update it.

Michael
 
Upvote 0
I'll attach the macro using this construct to a command button
OK. I will under the mistaken assumption that you didn't actually want 20 different buttons (one for each sheet), but it sounds like you are OK with that.
 
Upvote 0
No worries,

I'm not sure that using select case will be any easier to construct rather than separate macros if you are placing a button on every sheet anyway, tidier I suppose.
 
Upvote 0
Either way, I would have to create different message boxes but I thought I would use the select case just so I can get used to using it. The button is going on a userform so I thought this would be more efficient.

Michael
 
Upvote 0
The button is going on a userform so I thought this would be more efficient.
Ah, yes. That would make more sense. Didn't realize that you were using User Forms here (which is why I was asking where you planned to put the button).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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