Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using Variables in ActiveCell.Formula
Don't use FormulaR1C1 for a formula using normal ranges, use just Formula...
ActiveCell.Formula = "=Sum(" & StartCell & ":" & EndCell & ")" -- Rick (MVP - Excel) "dustinbrearton via OfficeKB.com" <u44989@uwe wrote in message news:8a93d2a582f55@uwe... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using Variables in ActiveCell.Formula
Hi
Use ActiveCell.Formula , not ActiveCell.FormulaR1C1 Regards, Per "dustinbrearton via OfficeKB.com" <u44989@uwe skrev i meddelelsen news:8a93d2a582f55@uwe... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using Variables in ActiveCell.Formula
Do'h. I did not even notice that was on there. Thanks.
Rick Rothstein wrote: Don't use FormulaR1C1 for a formula using normal ranges, use just Formula... ActiveCell.Formula = "=Sum(" & StartCell & ":" & EndCell & ")" I am trying to use the below code to insert "=SUM(D2:D3)" [quoted text clipped - 15 lines] of the ' so that the formula will actually work? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200809/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If activecell.column = variable then activecell,offset (0,1) | Excel Discussion (Misc queries) | |||
How to Revert to ActiveCell.Formula = format from ActiveCell.FormulaR1C1 = format | Excel Programming | |||
use of activecell.formula | Excel Programming | |||
ActiveCell.Formula Help | Excel Programming | |||
Formula with an ActiveCell | Excel Programming |