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

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Can Piwik report referrer in real time? -