I have a listbox that is populated dynamically by hidden tab names that start with the name "TEMP".
Private Sub UserForm_Initialize()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "TEMP*" Then
ListBoxTemp.AddItem (ws.Name)
End If
Next ws
End Sub
Then I have a button that is linked to the following Sub. When clicked each selected item in the listbox unhides the corresponding sheet.
Private Sub ButtonLoad_Click()
Dim i As Integer, sht As String
For i = 0 To ListBoxTemp.ListCount - 1
If ListBoxTemp.Selected(i) = True Then
sht = ListBoxTemp.List(i)
Sheets(sht).Visible = xlSheetVisible
End If
Next i
End
End Sub
This method works. But I would like the sheets to hide/unhide dynamically without having to click a button. I have tried a few methods using ListBoxTemp_Click(), but can not get it to work properly.
Any thoughts on how to accomplish this?
Bookmarks