Referencing a string within an Index Formula Array in Excel VBA ROW(1:1) -
need referencing string in index formula array
my code below:
sub loop_test2() dim long dim j long dim countall long dim countxl long dim customername string activesheet.range("a1").activate countall = activesheet.range("a35") j = 1 countall = 2 countxl = cells(i, j).value r = 1 = 1 countxl customername = cells(1, j).value 'msgbox customername msgbox r cells(i + 2, j).formulaarray = "=iferror(index(sheet2!$a:$b,small(if(sheet2!$a:$a=""" & customername & """,row(sheet2!$a:$a)),row(r:r))*1,2),0)" r = r + 1 next next j end sub
i trying put reference in part:
row(1:1)
change to:
row(""" & r & """ : """ & r & """)
however receiving object error 1004
delete double quotes
row(" & r & " : " & r & ")
full:
cells(i + 2, j).formulaarray = "=iferror(index(sheet2!$a:$b,small(if(sheet2!$a:$a=""" & customername & """,row(sheet2!$a:$a)),row(" & r & ":" & r & "))*1,2),0)"
example understand:
a = 10 b = "sometext_" & & "_sometext"
?b in immediate window (ctrl+g) print:
sometext_10_sometext
b = "sometext_""" & & """_sometext"
will print:
sometext_"10"_sometext
double quotes in editor goes quote in variable.
Comments
Post a Comment