First time here, so big hi everyone!
I've been pulling my hair for hours and was wondering if anyone can help me before i get bald
Im trying to remove all items from listbox1 that are in listbox2. All the code is working find until it needs to remove the item in an arry. Thats the part where im getting an invalid argument error. Can someone please help me with this?
I've been pulling my hair for hours and was wondering if anyone can help me before i get bald
Im trying to remove all items from listbox1 that are in listbox2. All the code is working find until it needs to remove the item in an arry. Thats the part where im getting an invalid argument error. Can someone please help me with this?
Code:
Private Sub CompareListboxes(lsb1 As MSForms.ListBox, lsb2 As MSForms.ListBox)
Dim i As Long
Dim x As Integer, Tabl()
ReDim Tabl(0)
For i = 0 To lsb1.ListCount - 1
x = x + 1
ReDim Preserve Tabl(x)
Tabl(x) = lsb1.List(i)
Next i
For i = 0 To lsb2.ListCount - 1
If IsNumeric(Application.Match(lsb2.List(i), Tabl, 0)) Then
lsb1.RemoveItem lsb2.List(i) ' <----- Error here
End If
Next i
End Sub