Re Post Please help: Listboxes question
Hi K,
In Excel 2007 I created this:
Private Sub CommandButton1_Click()
Dim L1 As Integer
Dim L2 As Integer
Dim LB1 As String
Dim LB2 As String
ReDim UM1(Me.ListBox1.ListCount - 1) As String
ReDim UM2(Me.ListBox2.ListCount - 1) As String
For L1 = 0 To Me.ListBox1.ListCount - 1
UM1(L1) = Me.ListBox1.List(L1)
Next
For L2 = 0 To Me.ListBox2.ListCount - 1
UM2(L2) = Me.ListBox2.List(L2)
Next
For L1 = 0 To Me.ListBox1.ListCount - 1
LB1 = Me.ListBox1.List(L1)
For L2 = 0 To Me.ListBox2.ListCount - 1
LB2 = Me.ListBox2.List(L2)
If LB1 = LB2 Then
MsgBox LB1, , "Matched"
UM1(L1) = ""
UM2(L2) = ""
End If
Next
Next
For L1 = 0 To Me.ListBox1.ListCount - 1
If UM1(L1) < "" Then
MsgBox UM1(L1), , "listbox 1 Unmatched"
End If
Next
For L2 = 0 To Me.ListBox2.ListCount - 1
If UM2(L2) < "" Then
MsgBox UM2(L2), , "listbox 2 Unmached"
End If
Next
End Sub
HTH,
Wouter
|