excel - Evaluate sumproduct -
i can't evaluate sumproduct @ end of code. think else working keep getting
type mismatch error
i've tried sorts of variations of syntax , still can't work. ideas?
sub sample() dim ws worksheet dim x long dim lrow long, llrow long dim acell range, bcell range dim rng1 range, rng2 range set ws = thisworkbook.sheets("sheet1") ws set acell = .range("b6:e20").find(cells(14, 9).offset(0, -1).value) if not acell nothing lrow = .range(split(.cells(, acell.column).address, "$")(1) & .rows.count).end(xlup).row if lrow > 1 set rng1 = .range(acell.offset(1), .cells(lrow, acell.column)) end if end if set bcell = .range("b6:e20").find(cells(14, 9).offset(-1, 0).value) if not bcell nothing llrow = .range(split(.cells(, bcell.column).address, "$")(1) & .rows.count).end(xlup).row if llrow > 1 set rng2 = .range(bcell.offset(1), .cells(lrow, bcell.column)) end if end if debug.print rng1.address debug.print rng2.address x = evaluate("=sumproduct(""rng1"",""rng2"")") end end sub
rng1
, rng2
doesn't mean sumproduct
function not named range
or valid range address. , evaluate
function fails.
to make work try:
x = evaluate("=sumproduct(" & rng1.address & "," & rng2.address & ")")
now make sure evaluate correct ranges, might want set external argument of address property true.
x = evaluate("=sumproduct(" & rng1.address(, , , true) & _ "," & rng2.address(, , , true) & ")")
Comments
Post a Comment