Excel VBA: cannot Sum() over Range() -
how should fix code because throws: "the object doesn't support property or method"
sub macro1() workbooks("output.xls").sheets("sheet1").activate activesheet.range("b4") = _ workbooks("input.xlsx").sheets("sheet1").sum(range("d40:d50")) end sub
above code works fine when adjusted as:
sub macro2() workbooks("output.xls").sheets("sheet1").activate activesheet.range("b4") = _ workbooks("input.xlsx").sheets("sheet1").range("d40") end sub
however it's not acceptable solution because want sum() on range() described in macro1().
worksheet doesn't have sum function, try using worksheetfunction instead:
sub macro1() workbooks("output.xls").sheets("sheet1").activate activesheet.range("b4") = _ application.worksheetfunction.sum(workbooks("input.xlsx").sheets("sheet1").range("d40:d50")) end sub
Comments
Post a Comment