Hi,
I have a combo box that is designed as a sheet navigator. The Cell link is . I have set up the following code that uses the cell link “voice” to select the relevant sheet. This works but I am wondering if there is a more elegant approach than using multiple IF statements?
“voice” is a numeric. Is it possible to convert that from a numeric to a string that represents the sheet name in order to convert to a worksheet for selection, rather than using multiple IF’s ??
I hope this is clear.
[codebox]
Sub FullView()
Dim tm1 As Worksheet, tm2 As Worksheet, _
lge As Worksheet, lgb As Worksheet, lgg As Worksheet, lgf As Worksheet, _
pla As Worksheet, plg As Worksheet, pld As Worksheet, plm As Worksheet, pls As Worksheet, _
adm As Worksheet
Dim voice As String
Set adm = Worksheets(“Admin”)
Set tm1 = Worksheets(“Teams (1)”)
Set tm2 = Worksheets(“Teams (2)”)
Set lge = Worksheets(“Entire League”)
Set lgb = Worksheets(“Boys”)
Set lgg = Worksheets(“Girls”)
Set lgf = Worksheets(“Finance”)
Set pla = Worksheets(“Players”)
Set plg = Worksheets(“GK”)
Set pld = Worksheets(“DEF”)
Set plm = Worksheets(“MID”)
Set pls = Worksheets(“STR”)
voice = adm.Range(“D21”)
If voice = 1 Then
Exit Sub
End If
If voice = 2 Then
tm1.Select
End If
If voice = 3 Then
tm2.Select
End If
If voice = 4 Then
lge.Select
End If
If voice = 5 Then
lgb.Select
End If
If voice = 6 Then
lgg.Select
End If
If voice = 7 Then
lgf.Select
End If
If voice = 8 Then
pla.Select
End If
If voice = 9 Then
plg.Select
End If
If voice = 10 Then
pld.Select
End If
If voice = 11 Then
plm.Select
End If
If voice = 12 Then
pls.Select
End If
adm.Range(“D21”) = 1
End Sub
[/codebox]