Select Variable sheet name

whcmelvin

Board Regular
Joined
Jul 27, 2011
Messages
82
Hi this is my code. I want to select the sheet name that is the same as the login name. Each login name will have a sheet of its own.
i tried this code and i have error on Sheets(Variable).Select

Email = Sheets("Trading Platform").LoginName.Value
Variable = Email
MsgBox Email
Sheets(Variable).Select
 
The sheet is already in my workbook. No need to create as all user will automatically have a sheet name afte their email
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
The sheet exist in the workbook. Every user will have a sheet name after their email address automatically.
 
Upvote 0
I'm not sure how it produced an error with resume next set. but oh well. Try this.

Code:
Sub login()
    On Error Resume Next
    Dim userSheet As Worksheet
    Set userSheet = Sheets(Range("LoginName").Value)
    If userSheet Is Nothing Then Exit Sub
    With userSheet
        .Visible = True
        .Select
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

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