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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -