Compare values in two columns and return the value from third [Closed]

Report
-
venkat1926
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
-
Hello,
I've a table containing four columns. If the values in the first two columns match to particular value (eg. A1="xxxx" and B1="yyy"), I need to return the value in the third column to the fourth column.
Can anybody help??? Thanks in advance.


1 reply

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
790
suppose data like this

col2 col3 col4 col1
x y f t
w w x s
c t c d
d y v f
x y g u
x y y n
q w m j
e r l k
t y k l


try this macro
Sub test()
Dim col1, col2, ccol
Set col1 = Range(Range("A2"), Range("A2").End(xlDown))
For Each ccol In col1
If ccol = "x" And ccol.Offset(0, 1) = "y" Then
ccol.Offset(0, 3) = ccol.Offset(0, 2)
End If
Next ccol
End Sub