Saturday, October 24, 2015

ListBox Column Adding – Deleting

In The ListBox  Column Adding – Deleting |  Listbox Column Management

       Before in this template,we fill data   to the listbox from a page with the following codes :

ListBox1.ColumnWidths = "92;140;110;65;65;35;40;65;65;115;150;65"
ListBox1.ColumnCount = 12
ListBox1.List = Sheets("Data").Range("A2:L" & [A65536].End(3).Row).Value

    After ,  those columns that we choose   can be removed  with check boxes. It does not affect the data on this page.

Example codes of checkbox1 :

Private Sub CheckBox1_Click()
Application.ScreenUpdating = False
If CheckBox1.Value = True Then
For sat = 2 To Cells(65536, 1).End(xlUp).row
ListBox1.AddItem
ListBox1.List(s, 0) = Cells(sat, 1)
s = s + 1
Next
     Else
For i = 0 To ListBox1.ListCount - 1
        ListBox1.column(0, i) = Empty
     Next i
End If
Application.ScreenUpdating = True
End Sub