What am I doing wrong here?
When I run the code I get =INDEX(RNG2,MATCH(G2,RNG3,0)) in Z2
What I'm trying to get is =INDEX(AL2:AL21182,MATCH(G2,AM2:AM21182,0))
I also tried it like this
Thank you
When I run the code I get =INDEX(RNG2,MATCH(G2,RNG3,0)) in Z2
What I'm trying to get is =INDEX(AL2:AL21182,MATCH(G2,AM2:AM21182,0))
VBA Code:
Dim rng, rng2, rng3 As Range, a, i As Long
Set rng = Range("W2")
Set rng2 = Range("AL2:AL" & Range("AL" & Rows.Count).End(xlUp).Row)
Set rng3 = Range("AM2:AM" & Range("AL" & Rows.Count).End(xlUp).Row)
If rng.Offset(0, 1).Value = 1 Then
Range("Z2") = "=INDEX(" & rng2 & ",MATCH(G2," & rng3 & ",0))"
I also tried it like this
VBA Code:
Range("Z2") = "=INDEX(rng2,MATCH(G2,rng3,0))"
Thank you