VBA Editor

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help! I cant figure out how to use the If-Then-Else Control Function. I need to go to a selected sheet
 
Please post more details.
--
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
http://www.r-cor.com

Sun said:
Help! I cant figure out how to use the If-Then-Else Control Function. I
need to go to a selected sheet
 
Bit light on details, but here is an idea

If myVar = 1 Then
Worksheets("Sheet1").Activate
ElseIf myVar = 7 Then
Worksheets("Sheet2").Activate
ElseIf myVar = 11 Then
Worksheets("Sheet3").Activate
'etc.
End If

or using Case


Select Case myVar
Case 1 : Worksheets("Sheet1").Activate
Case 7 : Worksheets("Sheet2").Activate
Case 11 : Worksheets("Sheet3").Activate
'etc.
End Select
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Sun said:
Help! I cant figure out how to use the If-Then-Else Control Function. I
need to go to a selected sheet
 
Back
Top