Excel VBA Active WorkSheet Name

hunter.t.j

New Member
Joined
Mar 20, 2007
Messages
23
I would like to find out the WorkSheet Name Of the Current work sheet so that I may check it to see if the user is on the right WorkSheet.

If variable <> "RIGHT" Then
I then want to make the correct sheet active using the name I just tested for.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
x = ActiveSheet.Name
If x <> "RIGHT" then Sheets("RIGHT").Select


Although, it might be simpler just to select the correct sheet, rather than test if the right sheet is selected first...

Sheets("RIGHT").Select

It will not error if the RIGHT sheet is already active..
 
Upvote 0
Sub testme()
Mysheet = ActiveSheet.name
If Mysheet <> "Sheet1" Then Sheets("Sheet1").Activate
End Sub

But if the user only needs one sheet why not activate that in a workbook open or something?
 
Upvote 0

Forum statistics

Threads
1,214,521
Messages
6,120,018
Members
448,937
Latest member
BeerMan23

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