Go to sheet using Dim as string

husoi

Board Regular
Joined
Sep 12, 2012
Messages
50
Can anyone help please?
For those who saw my previous post, this is the continuation and my next problem.

I'm using this macro so the users can return to the project front page when finished and it is working up to the message box.
The bit where I'm stuck is when I try to use the Dim (subpage) to go to the initial page.
As explained on the other post, I'm using "12345W" for front sheet name and then "12345WA1"; "12345WA2"; "12345WA3"; "12345WA4"; "12345WA5"; as subtabs
The subpage = Left(ActiveSheet.Name, 6) code works beautifully and the message box shows exactly what I want ("12345W").

Sub button_click_return()
Dim subpage As String

subpage = Left(ActiveSheet.Name, 6)
MsgBox "Going to project front page:" & subpage

How on Earth I use this bit??? :confused::(
Sheets(ActiveSheet(subpage)).Activate
End Sub

Thank you for your help;)
PS: almost forgot. this is to be used in the 5 longer name sheets (over 6 Char) and is intended to return to the shorter name page (6 Char).
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,224,621
Messages
6,179,938
Members
452,949
Latest member
beartooth91

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