Compare values in two columns and return the value from third

Closed
Wasim - Mar 9, 2016 at 08:02 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Mar 10, 2016 at 07:27 AM
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 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Mar 10, 2016 at 07:27 AM
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
0