Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Sum Formula in Macro

I have a macro that enters a sum formula into a cell and copies the formula
to several columns. The formula works in the initial cell but is simply
duplicated in the other columns when I want it to copy the formula using
relative cell addresses. Here is the formula in the macro:

ActiveCell.FormulaR1C1 = "=Sum(FIRSTROW:LASTROW)"

The named ranges FIRSTROW and LASTROW have been correctly set previously in
the macro.

Does anyone have any ideas?

Thank you

Tim U
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Sum Formula in Macro

If you have named ranges in your formula, they will always be absolute
references.

--

Vasant

"Tim U" wrote in message
...
I have a macro that enters a sum formula into a cell and copies the

formula
to several columns. The formula works in the initial cell but is simply
duplicated in the other columns when I want it to copy the formula using
relative cell addresses. Here is the formula in the macro:

ActiveCell.FormulaR1C1 = "=Sum(FIRSTROW:LASTROW)"

The named ranges FIRSTROW and LASTROW have been correctly set previously

in
the macro.

Does anyone have any ideas?

Thank you

Tim U



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Sum Formula in Macro

ActiveCell.FormulaR1C1 = "=Sum(" & FIRSTROW & ":" & LASTROW ")"

need to separate variables from text portion.

But I think you may mean:

ActiveCell.FormulaR1C1 = "=Sum(R" & FIRSTROW & "C:R" & LASTROW "C)"

And consider no copy/paste with something like:

Range(Cells(LASTROW + 1, col1),Cells(LASTROW +1,col2)FormulaR1C1 = "=Sum(R"
& FIRSTROW & "C:R" & LASTROW "C)"

You'll need to either figure col1 & col2 or set values.
--
steveB

Remove "AYN" from email to respond
"Tim U" wrote in message
...
I have a macro that enters a sum formula into a cell and copies the formula
to several columns. The formula works in the initial cell but is simply
duplicated in the other columns when I want it to copy the formula using
relative cell addresses. Here is the formula in the macro:

ActiveCell.FormulaR1C1 = "=Sum(FIRSTROW:LASTROW)"

The named ranges FIRSTROW and LASTROW have been correctly set previously
in
the macro.

Does anyone have any ideas?

Thank you

Tim U



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Sum Formula in Macro

Ah, Vasant, you should be careful with such claims.

Suppose you have some numbers in A2:B13 and want the row-by-row sum.
Select C2 and define the name aName as =Sheet3!$A2:$B2
(note the use of absolute and relative references).

Now, in C2 enter =SUM(aName). Copy C2 to C3:C13.

I think of this (the use of relative references in a named formula) as
a poor alternative to something that is otherwise impossible --
arguments to named formulas.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , "Vasant Nanavati"
<vasantn *AT* aol *DOT* com says...
If you have named ranges in your formula, they will always be absolute
references.


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
Macro or Formula terilad Excel Discussion (Misc queries) 5 March 5th 10 09:49 PM
Formula or Macro A.S. Excel Discussion (Misc queries) 6 March 5th 08 01:16 AM
Formula or Macro M Hebert Excel Discussion (Misc queries) 2 June 27th 07 01:24 PM
Is there a Formula or Macro for This? Marilyn Excel Discussion (Misc queries) 8 May 7th 07 05:03 PM
Formula Macro Secret Squirrel Excel Discussion (Misc queries) 7 January 27th 07 04:16 PM


All times are GMT +1. The time now is 01:10 PM.

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"