excel - Set a range and use that range in a formula -


i unable figure out how use set range in formula:

set range = application.inputbox(prompt:="test", title:="test", type:=8) sheets("sheet1").cells(3, 4).formula = "=sum(range)" 

all returned sum(range), not actual sum of selected cells.

i've tried range.address , couple other variations no avail.

your formula string, need concatenate range address formula:

sheets("sheet1").cells(3, 4).formula = "=sum(" & range.address & ")" 

you should use different name variable, however, range built-in type/function in excel vba.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -