Hi, I have a table with 2 columns (L & M), the number of rows in the table can change so I want to search using the current number of rows.
For a fixed number of rows (7) this formula works
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH($L$2:$L$7,$D1),$M$2:$M$7),$E1)"
But I can't figure out how to make $L$7 and $M$7 dynamic
I use this to get the current number of rows "x":
x = Cells(Rows.Count, "L").End(xlUp).Row
I've tried a number of ways but can't get the right syntax. e.g.
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH(range("$L$2:$L$" &x,$D1),range("$M$2:$M$" &x),$E1)"
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH(range("$L$2"),"$L$" & x,$D1),range("$M$2","$M$" &x),$E1)"
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH((range("L2","L" & x)).address,$D1),(range("M2","M" &x)).address,$E1)"
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH("("&range("L2","L" & x&")").address,$D1),"("&range("M2","M" &x&)")".address,$E1)"
I'd appreciate any help.
For a fixed number of rows (7) this formula works
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH($L$2:$L$7,$D1),$M$2:$M$7),$E1)"
But I can't figure out how to make $L$7 and $M$7 dynamic
I use this to get the current number of rows "x":
x = Cells(Rows.Count, "L").End(xlUp).Row
I've tried a number of ways but can't get the right syntax. e.g.
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH(range("$L$2:$L$" &x,$D1),range("$M$2:$M$" &x),$E1)"
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH(range("$L$2"),"$L$" & x,$D1),range("$M$2","$M$" &x),$E1)"
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH((range("L2","L" & x)).address,$D1),(range("M2","M" &x)).address,$E1)"
Range("I1").Formula2 = "=IFERROR(LOOKUP(2,1/SEARCH("("&range("L2","L" & x&")").address,$D1),"("&range("M2","M" &x&)")".address,$E1)"
I'd appreciate any help.