excel - Auto filling formula VBA -
looking vba function
i have data on 2 sheets need perform index match on.
the data size vary every time compare run.
i have coded vba call data , populate both sheets running comparison causing problem.
i have created below function, running without error not populating formula in cell starting j2 end of j range.
sub formulafill() dim strformulas(1 1) variant thisworkbook.sheets("export worksheet") strformulas(1) = "=index('sheet1'!e:e,match('export worksheet'!a2,'sheet1'!a:a,0))" .range("j:j").filldown end end sub
any appreciated.
w
image after updated code applied
you writing formula array variable, not cell, tried fill entire column using j:j
. means trying fill entire column contents of cell j1
, top cell, not j2
.
here code corrections.
sub formulafill() thisworkbook.sheets("export worksheet") .cells(2, 10).formula = "=index('sheet1'!e:e,match('export worksheet'!a2,'sheet1'!a:a,0))" .range(.cells(2, 10), .cells(.cells(.rows.count, 9).end(xlup).row, 10)).filldown end end sub
the .cells(.rows.count, 9).end(xlup).row
determines last filled row of column 9 (i) , code uses number in range use autofill of column 10 (j)
Comments
Post a Comment