Thread: Comparing lists
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sheeny[_11_] Sheeny[_11_] is offline
external usenet poster
 
Posts: 1
Default Comparing lists

Hi,
Any help would be greatly appreciated.

I have two lists, old and new. I used the conditional formatting in
Excel to highlight and bold those in Old that do not appear in New, and
those in New that do not appear in old.

Now, I have two listboxes, one entitled Old and one entitled New. I
want to loop through cells A4:A135 and print those that are bold (
because they dont appear in New) in ListOld and similarly, want to loop
thorugh cells B4:B135 and print those that are bold in ListNew.

After coding this I found that it does not work for fields that are
conditionally bold. So I moved on to compare the lists, and print
those in Old that do not appear in New.

I came up with this:

Private Sub CmdRec_Click()

Dim i As Long

ListOld.Clear

Sheet3.Activate
Sheet3.Range("A4").Select

With Sheet3

For i = 1 To .Range("B" & Rows.Count).End(xlUp).Row
For j = 1 To .Range("A" & Rows.Count).End(xlUp).Row
If Sheet3.Cells(i, "B").Value < Sheet3.Cells(i,
"A").Value Then
ListOld.AddItem (Sheet3.Cells(i, "A").Value)
End If
Next j
Next i

End With

End Sub

Two problems with this:

1. It starts at A1 but I want it to start at A4
2. It prints the 'old' company NUMEROUS times, I guess everytime it
loops through the loop.

Any ideas on how to get what I want?

Thanks!!!
Sheeny


---
Message posted from http://www.ExcelForum.com/