Excel comparision

Solved/Closed
NITESH - Jan 8, 2012 at 08:31 AM
 Nitesh - Jan 31, 2012 at 12:51 PM
hello,
can any one help me solve the following comparison problem..


a(reference data) b(raw data) c(status)

ab xc
bc cb
cd ab match
ef pq
gh cd match
ij zx
kl qr
hj
rh
bc match
kl match


pls.. help to solve this problem of excel.

nitesh


Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Jan 17, 2012 at 10:07 AM
Hi NITESH,

Your query is unclear to me.

I quess you want to compare your reference data with your raw data and when there is a match, then enter match in the third column.
What would you consider a match?

Please explain in greater detail.

Best regards,
Trowa
0
hi
i really appreciate that u did consider my question ,
My q is if a is a reference data in a sheet 1in any column(say A) and b is a Raw data in sheet 2 in any column(say D),then Raw data must be compared with the reference data of sheet1,and if any match found then that match will be copy to the sheet3 of same workbook..

A(reference data) D(raw data) A(status)
ab xc
bc cb
cd ab match
ef pq
gh cd match
ij zx
kl qr
hj bc MATCH
rh
ch

pls.. help to solve this problem of excel.
thanks in advance.
nitesh
0
hi
i really appreciate that u did consider my question ,
My q is if a is a reference data in a sheet 1in any column(say A) and b is a Raw data in sheet 2 in any column(say D),then Raw data must be compared with the reference data of sheet1,and if any match found then that match will be copy to the sheet3 of same workbook..


A(reference data) D(raw data) A(status)
ab --------- --------- xc
bc---------- ------ cb
cd ------------- ab match
ef ------------pq
gh --------- cd match
ij ------------ zx
kl------------- qr
hj ------------- bc MATCH
rh
ch

pls.. help to solve this problem of excel.
thanks in advance.
nitesh
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Jan 19, 2012 at 09:58 AM
Hi NITESH,

Sheet1, column A, Header: Reference data.
Sheet2, column D, Header: Raw data.
Sheet3, column A, Header: Status

If this is ok, then try this code:
Sub Compare()
Dim lRow, lRow2, x As Integer
lRow = Sheets("Sheet2").Range("D" & Rows.Count).End(xlUp).Row
lRow2 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
For Each cell In Sheets("Sheet2").Range("D2:D" & lRow)
x = 2
Do
If cell.Value = Sheets("Sheet1").Range("A" & x) Then
Sheets("Sheet3").Range("A" & cell.Row).Value = "Match"
End If
x = x + 1
Loop Until x > lRow2
Next cell
End Sub

Does this yield the desired result?

Best regards,
Trowa
0
thanks for your help! Trowa ,but can you pls.. tell me how to place the above code in a vba editor window and on which sheet i have to put it and save it and how to run it?

Thanks again
Nitesh
0
sorry to bother u again but when i run this code it run but it is unable to find all match.for example if there is 3 match in raw data of same value then it is shows match only for one .there also some more prob.but this one is main..
thanks again
0