changing a formula range in visual basic

O

OoM JaN

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?
 
D

Don Guillett

x=10
Range("b5").Formula = "=sum(a1:a" & x & ")"
'or below to leave just the value
'range("b5")=application.sum(range("a1:a" & x))
 
Top