changing a formula range in visual basic

  • Thread starter Thread starter OoM JaN
  • Start date Start date
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?
 
x=10
Range("b5").Formula = "=sum(a1:a" & x & ")"
'or below to leave just the value
'range("b5")=application.sum(range("a1:a" & x))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top