tinkythomas
Active Member
- Joined
- Dec 13, 2006
- Messages
- 432
Hi,
I have a userform with a multiselect listbox with checkboxes. These checkboxes represent the columns in the activesheet.
I have written code to populate the listbox with the used column headers in the activesheet. The listbox takes these values from an array.
My question is how do I get the checkboxes selected and then hide the applicable columns on the activesheet?
The code I have so far...
Any help would be appreciated.
Regards,
I have a userform with a multiselect listbox with checkboxes. These checkboxes represent the columns in the activesheet.
I have written code to populate the listbox with the used column headers in the activesheet. The listbox takes these values from an array.
My question is how do I get the checkboxes selected and then hide the applicable columns on the activesheet?
The code I have so far...
Code:
Option Explicit
Option Base 1
Private Sub UserForm_Initialize()
Dim rng As Range
Dim i As Integer, _
lc As Integer
Dim arr() As String
lc = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = ActiveSheet.Range(Cells(1, 1), Cells(1, lc))
For i = LBound(rng.Cells.Value2, 2) To UBound(rng.Cells.Value2, 2)
ReDim Preserve arr(1 To i)
arr(i) = rng.Cells.Value2(1, i)
Next i
ListBox1.List = arr
Set rng = Nothing
End Sub
Any help would be appreciated.
Regards,