View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dustinbrearton via OfficeKB.com dustinbrearton via OfficeKB.com is offline
external usenet poster
 
Posts: 46
Default Using Variables in ActiveCell.Formula

I am trying to use the below code to insert
"=SUM(D2:D3)"


LastStop = 1
X = 4

StartCell = "D" & LastStop + 1
EndCell = "D" & X - 1
ActiveCell.FormulaR1C1 = "=Sum(" & StartCell & ":" & EndCell & ")"

The result of the activecell.formula line is "=Sum('D2':'D3')"

For ease of explanation I have set LastStop and X to certain numbers. In my
code these two variables change based on where the set ends.

Where have I gone wrong in the ActiveCell.Formula line? How do I get rid of
the ' so that the formula will actually work?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1