I am trying to add and remove items from an activex listbox with multiple columns.
Whis this code I only remove parts of the items in the listbox and in the rowsource, I think you could say that it doesn't remove all columns.
Code to remove items:
Code to add items:
What is a good way to add/remove items from a listbox? How can I delete items in the listbox and in the rowsource? Should my rowsource be a table?
Whis this code I only remove parts of the items in the listbox and in the rowsource, I think you could say that it doesn't remove all columns.
Code to remove items:
Code:
Private Sub CommandButton2_Click()
Dim sFind As String, rFound As Range
Select Case Me.ListBox1.Value
Case Is <> vbNullString
sFind = Me.ListBox1.Value
With Sheet2
Set rFound = .Cells.Find(what:=sFind, After:=.Cells(1, 1))
If Not rFound Is Nothing Then
rFound.Delete Shift:=xlUp
End If
End With
Case Else: Exit Sub
End Select
End Sub
Code to add items:
Code:
Dim lRow As Long
Dim ws As Worksheet
Set ws = Sheet3
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.ComboBox10.Value
.Cells(lRow, 2).Value = Me.TextBox100.Value
.Cells(lRow, 3).Value = Me.ComboBox11.Value
.Cells(lRow, 4).Value = Me.TextBox101.Value
.Cells(lRow, 5).Value = Me.TextBox102.Value
.Cells(lRow, 6).Value = Me.TextBox103.Value
End With
End Sub
What is a good way to add/remove items from a listbox? How can I delete items in the listbox and in the rowsource? Should my rowsource be a table?