ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   changing a formula range in visual basic (https://www.excelbanter.com/excel-programming/298965-changing-formula-range-visual-basic.html)

OoM JaN

changing a formula range in visual basic
 
I need some help, I've been searching for some time and I guess the answer
is simple, but for me it's puzzel.
I have a macro wich have to change a number of formules.
I want the macro to change the range in the formule. For example:


formuleinacell = "=sum(a1:a5")"
newrange=10

** some kind of code....**

newformuleinthecell = "=sum(a1:a10")"

what is the best way to program?



Don Guillett[_4_]

changing a formula range in visual basic
 
x=10
Range("b5").Formula = "=sum(a1:a" & x & ")"
'or below to leave just the value
'range("b5")=application.sum(range("a1:a" & x))
--
Don Guillett
SalesAid Software

"OoM JaN" wrote in message
news:dD6rc.1823$Bb6.40261@zonnet-reader-1...
I need some help, I've been searching for some time and I guess the answer
is simple, but for me it's puzzel.
I have a macro wich have to change a number of formules.
I want the macro to change the range in the formule. For example:


formuleinacell = "=sum(a1:a5")"
newrange=10

** some kind of code....**

newformuleinthecell = "=sum(a1:a10")"

what is the best way to program?






All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com