Compare multiple listbox contents
Hi everyone, Im hoping someout out there can help me with this one. I have two listboxes, i want to create a third one based on the results of the contents of the other two. EG :- Listbox three shows everything that is different between listbox 1 and 2. So if listbox 1 has :- a,b,c,d,e,f,g & listbox 2 has :- b,c,e,f I need listbox three to show :- a,d,g etc etc. has anybody done this, and can anybody help please ??. :confused: -- TASDEVIL ------------------------------------------------------------------------ TASDEVIL's Profile: http://www.excelforum.com/member.php...o&userid=23109 View this thread: http://www.excelforum.com/showthread...hreadid=474637 |
Compare multiple listbox contents
Dim i As Long, j As Long
Dim fMatch As Long For i = 1 To ListBox1.ListCount fMatch = False For j = 1 To ListBox2.ListCount If ListBox1.List(i - 1) = ListBox2.List(j - 1) Then fMatch = True Exit For End If Next j If Not fMatch Then ListBox3.AddItem ListBox1.List(i - 1) End If Next i For i = 1 To ListBox2.ListCount fMatch = False For j = 1 To ListBox1.ListCount If ListBox2.List(i - 1) = ListBox1.List(j - 1) Then fMatch = True Exit For End If Next j If Not fMatch Then ListBox3.AddItem ListBox2.List(i - 1) End If Next i -- HTH Bob Phillips "TASDEVIL" wrote in message ... Hi everyone, Im hoping someout out there can help me with this one. I have two listboxes, i want to create a third one based on the results of the contents of the other two. EG :- Listbox three shows everything that is different between listbox 1 and 2. So if listbox 1 has :- a,b,c,d,e,f,g & listbox 2 has :- b,c,e,f I need listbox three to show :- a,d,g etc etc. has anybody done this, and can anybody help please ??. :confused: -- TASDEVIL ------------------------------------------------------------------------ TASDEVIL's Profile: http://www.excelforum.com/member.php...o&userid=23109 View this thread: http://www.excelforum.com/showthread...hreadid=474637 |
All times are GMT +1. The time now is 11:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com