Using a Database I am able to create an Output list from records checked in a Listbox.
The Command Button “Copy” reads the Listbox Selections and creates an Output in Column G; Columns H & I are displayed through the VLOOKUP function.
The code for “Copy” is:
Private Sub CommandButton1_Click()
Application.Calculation = xlCalculationManual
Dim lItem As Long
Dim YItem As Long
YItem = 0
For lItem = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lItem) = True Then
Range("G" & YItem + 1).Value = (ListBox1.List(lItem))
YItem = YItem + 1
End If
Next
Application.Calculation = xlCalculationAutomatic
End Sub
All of the above is fine.
My problem is to clear the valuse of the checkboxes in the Listbox with a macro attached to “Clear” button. I can clear Column G with a simple “Columns(“G:G”).ClearContents” statement. Now that database has some 130 records.
The Command Button “Copy” reads the Listbox Selections and creates an Output in Column G; Columns H & I are displayed through the VLOOKUP function.
The code for “Copy” is:
Private Sub CommandButton1_Click()
Application.Calculation = xlCalculationManual
Dim lItem As Long
Dim YItem As Long
YItem = 0
For lItem = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lItem) = True Then
Range("G" & YItem + 1).Value = (ListBox1.List(lItem))
YItem = YItem + 1
End If
Next
Application.Calculation = xlCalculationAutomatic
End Sub
All of the above is fine.
My problem is to clear the valuse of the checkboxes in the Listbox with a macro attached to “Clear” button. I can clear Column G with a simple “Columns(“G:G”).ClearContents” statement. Now that database has some 130 records.