laxstar785
New Member
- Joined
- Jul 27, 2011
- Messages
- 23
Hi Guys,
I just got some help the other day with my list box on here and now I am trying to hide the list box using a toggle button. Th issue I am having is I can either show and hide the list box using the toggle button. If i do this I can't click the actual list box. If I switch tabs and come back to the tab with the worksheet I can then use the list box but I can't show or hide it until i switch tabs and return again, my code is listed here below any help would be greatly appreciated. (thanks for the help on my list box Mick!).
I just got some help the other day with my list box on here and now I am trying to hide the list box using a toggle button. Th issue I am having is I can either show and hide the list box using the toggle button. If i do this I can't click the actual list box. If I switch tabs and come back to the tab with the worksheet I can then use the list box but I can't show or hide it until i switch tabs and return again, my code is listed here below any help would be greatly appreciated. (thanks for the help on my list box Mick!).
Code:
Private Sub ToggleButton1_Click()
If ToggleButton1 Then
Sheet2.Shapes("ListBox2").Visible = True
Else
Sheet2.Shapes("ListBox2").Visible = False
End If
End Sub
'This code Enters the Headers into the ListBox
Private Sub Worksheet_Activate()
With ListBox2
.List = Application.Transpose(Range("A2:O2").Value)
.MultiSelect = fmMultiSelectMulti
End With
End Sub
Private Sub CommandButton3_Click()
'Columns Hidden/Unhidden, as per selected headers
Dim Rng As Range
Dim n As Integer
Dim dn As Range
With ListBox2
For n = 0 To .ListCount - 1
If .Selected(n) Then
Columns(n + 1).Hidden = True
Else
Columns(n + 1).Hidden = False
End If
Next n
End With
If Not Rng Is Nothing Then
For Each dn In Rng.Columns
dn.Columns.Hidden = True
Next dn
End If
End Sub
[End-Code]