Home > OS >  write dynamic formula in cell using vba
write dynamic formula in cell using vba

Time:03-25

Range(A1).Value = "=SUM(Range(B1), Range(B1).Offset(xlToRight))"

I want to write a formula in a cell by using VBA, but I want to make it dynamic.
How can I write this code?
What I've tried is written above.

CodePudding user response:

try this:

Range("A1").Formula = "=SUM(" & Range("B1").Value & "," & Range("B1").Offset(0, 1).Value & ")"

  • Related