Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
How to Revert to ActiveCell.Formula = format from ActiveCell.FormulaR1C1 = format Karthik Bhat - Bangalore[_2_] Excel Programming 1 May 9th 07 02:37 PM
use of activecell.formula R..VENKATARAMAN Excel Programming 2 May 12th 06 04:50 AM
ActiveCell.Formula Help Srikanth Ganesan[_2_] Excel Programming 1 September 2nd 04 10:38 PM
Formula with an ActiveCell Sok Hong Excel Programming 3 August 14th 03 08:24 AM


All times are GMT +1. The time now is 07:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"