[RESOLVED] Using a Cell value to select worksheet
Hello All,
Been a while since I haunted you, hope all is well with you and yours!
My question is this:
Is there a code that will select a sheet based on the value of a worksheet cell or even better, a label caption? The cell or label number value is a known valid sheet number.
For example:
If I have a label in a Userform that is named "ReportNo" and the value in that label is "11-11-SR". I have a valid Worksheet named 11-11-SR. I need a code that will make that sheet the Activesheet based on the value of ReportNo.
Kinda like this? Worksheets("Me.ReportNo").Select
Thanks very much in advance!
John
Re: Using a Cell value to select worksheet
try
vb Code:
Worksheets(Me.ReportNo).Select
Re: Using a Cell value to select worksheet
Thanks for the response!
That still isn't working..I had tried that earlier too.
Below is the code that I'm trying to get working. Be advised, I created a label in the same, Userform that the CB "End_Storm" resides (LbTest), for testing purposes and the default caption is "11-11-SR" (no quotations). I have confirmed that the Worksheet exists as when entered as Worksheets("11-11-SR").Select, the code works fine.
Private Sub End_Storm_Click()
Worksheets(Me.LbTest).Select
Range("A1") = "test"
MsgBox "Test"
End Sub
The error response is "Runtime error '13' Type mismatch.
Thanks again for taking the time, I really do appreciate it!
John
Re: Using a Cell value to select worksheet
Re: Using a Cell value to select worksheet
Try this
Worksheets(Trim(ReportNo.Caption)).Select
I just tried it and it works....
Sid
Re: Using a Cell value to select worksheet
Koolsid....YOU are the man...that worked perfectly THANKS!