I'm using code I received lately and now trying to restrict it to only worksheets ending in LISTS for a new listbox on a new userform.
The original code is
My new NONWORKING code is
I'm attempting to have a VBA listbox that shows only worksheets that end in .LISTS
I've checked other forums searches (along with yours) and the web about listboxs but they seem to involve results from other sources. So simple a task and I'm lost.
After many fail attempts, I'm asking for help again. THANKS
The original code is
VBA Code:
Private Sub CommandButton1_Click()
Dim i As Integer, sht As String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
sht = ListBox1.List(i)
End If
Next i
Sheets(sht).Visible = True
ShGE04.Visible = False
Sheets(sht).Activate
End
End Sub
Private Sub CommandButton2_Click()
Unload Go_To_WS
End Sub
Private Sub UserForm_Initialize()
''''NoSparks @ Mr Excel 9.6.21
Dim sh As Worksheet, shtnames As String
For Each sh In ThisWorkbook.Worksheets
If sh.Name <> ActiveSheet.Name Then
shtnames = shtnames & "|" & sh.Name
End If
Next sh
ListBox1.List = Split(Mid(shtnames, 2), "|")
End Sub
My new NONWORKING code is
VBA Code:
Private Sub CommandButton1_Click()
Dim i As Integer, sht As String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
sht = ListBox1.List(i)
End If
Next i
Sheets(sht).Visible = True
ShGE04.Visible = False
Sheets(sht).Activate
End
End Sub
Private Sub CommandButton2_Click()
Unload Edit_Lists_UF
End Sub
Private Sub UserForm_Initialize()
Dim sh As Worksheet, shtnames As String
Dim ws As Worksheet
For Each sh In ThisWorkbook.Worksheets
If ws.Name Like "*.lists" Then
shtnames = ws.Name
End If
Next sh
End Sub
I'm attempting to have a VBA listbox that shows only worksheets that end in .LISTS
I've checked other forums searches (along with yours) and the web about listboxs but they seem to involve results from other sources. So simple a task and I'm lost.
After many fail attempts, I'm asking for help again. THANKS