Thread
:
Compare 2 Lists and Take an Action Q
View Single Post
#
3
Posted to microsoft.public.excel.programming
GS[_6_]
external usenet poster
Posts: 1,182
Compare 2 Lists and Take an Action Q
Hi Sean,
Am Fri, 18 Nov 2016 11:17:48 -0800 (PST) schrieb
:
I have 2 Lists of Data on the same sheet
List A is detailed in Columns A-D
List B is detailed in Column G-K
What I want to do is compare certain Columns/Rows in both Lists and
for each one that matches, place an X in Column E (covering List A)
and a corresponding X in Column L (covering List B). Note the
matched values will not be on the same Row in both
So what will be compared? if Col B & D rows matches somewhere with
Col H & K an X is placed on the appropriate Row in Cols E & L
try:
Sub CompareList()
Dim LRowA As Long, LRowB As Long, i As Long, j As Long
Dim varA As Variant, varB As Variant
With ActiveSheet
LRowA = .Cells(.Rows.Count, "A").End(xlUp).Row
LRowB = .Cells(.Rows.Count, "G").End(xlUp).Row
varA = .Range("A1:D" & LRowA)
varB = .Range("G1:K" & LRowB)
For i = LBound(varA) To UBound(varA)
For j = LBound(varB) To UBound(varB)
If varA(i, 2) & varA(i, 4) = varB(j, 2) & varB(j, 5) Then
.Cells(i, "E") = "x"
.Cells(i, "L") = "x"
??s/b?? .Cells(j, "L") = "x"
'If there is only one match possible delete the
apostroph in front of next line
'Exit For
End If
Next
Next
End With
End Sub
Regards
Claus B.
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB
Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb
.general.discussion
Reply With Quote
GS[_6_]
View Public Profile
Find all posts by GS[_6_]