Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JJ JJ is offline
external usenet poster
 
Posts: 122
Default Auto Sum cell above a relevant reference cell

How can I sum all cells above a cell. For instance I have spreadsheets with
varying numbers of rows, and I want to add a sum total at the bottom of each
of those columns. Since the number of rows is unknown, I am unsure of what to
put after the word "sum"....... Here is the code I have:

ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -2).Select
ActiveCell.FormulaR1C1 = "=SUM(?????????)"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Auto Sum cell above a relevant reference cell

cLastRow = Cells(Rows.Count,activecell.column).End(xlUp).Row
Cells(cLastRow+1,Activecell.column).FormulaR1C1="= SUM(R1C:R" & clastrow
& "C)"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JJ" wrote in message
...
How can I sum all cells above a cell. For instance I have spreadsheets

with
varying numbers of rows, and I want to add a sum total at the bottom of

each
of those columns. Since the number of rows is unknown, I am unsure of what

to
put after the word "sum"....... Here is the code I have:

ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -2).Select
ActiveCell.FormulaR1C1 = "=SUM(?????????)"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Auto Sum cell above a relevant reference cell


Hi Bob, Your solution works quite well but what if the first row contains
headings and you don't want that row included in the equation? This is how
the AutoSum icon works. Can a solution do that too?

TIA

JohnL

"Bob Phillips" wrote:

cLastRow = Cells(Rows.Count,activecell.column).End(xlUp).Row
Cells(cLastRow+1,Activecell.column).FormulaR1C1="= SUM(R1C:R" & clastrow
& "C)"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JJ" wrote in message
...
How can I sum all cells above a cell. For instance I have spreadsheets

with
varying numbers of rows, and I want to add a sum total at the bottom of

each
of those columns. Since the number of rows is unknown, I am unsure of what

to
put after the word "sum"....... Here is the code I have:

ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -2).Select
ActiveCell.FormulaR1C1 = "=SUM(?????????)"




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Auto Sum cell above a relevant reference cell

Sum ignores the header if it is text.

or you could do

cLastRow = Cells(Rows.Count,activecell.column).End(xlUp).Row
Cells(cLastRow+1,Activecell.column).FormulaR1C1="= SUM(R2C:R" & clastrow
& "C)"

--
Regards,
Tom Ogilvy

"JohnL" wrote in message
...

Hi Bob, Your solution works quite well but what if the first row contains
headings and you don't want that row included in the equation? This is

how
the AutoSum icon works. Can a solution do that too?

TIA

JohnL

"Bob Phillips" wrote:

cLastRow = Cells(Rows.Count,activecell.column).End(xlUp).Row
Cells(cLastRow+1,Activecell.column).FormulaR1C1="= SUM(R1C:R" &

clastrow
& "C)"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JJ" wrote in message
...
How can I sum all cells above a cell. For instance I have spreadsheets

with
varying numbers of rows, and I want to add a sum total at the bottom

of
each
of those columns. Since the number of rows is unknown, I am unsure of

what
to
put after the word "sum"....... Here is the code I have:

ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -2).Select
ActiveCell.FormulaR1C1 = "=SUM(?????????)"






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Auto Sum cell above a relevant reference cell

Thanks Tom, works great!

JohnL

"Tom Ogilvy" wrote:

Sum ignores the header if it is text.

or you could do

cLastRow = Cells(Rows.Count,activecell.column).End(xlUp).Row
Cells(cLastRow+1,Activecell.column).FormulaR1C1="= SUM(R2C:R" & clastrow
& "C)"

--
Regards,
Tom Ogilvy

"JohnL" wrote in message
...

Hi Bob, Your solution works quite well but what if the first row contains
headings and you don't want that row included in the equation? This is

how
the AutoSum icon works. Can a solution do that too?

TIA

JohnL

"Bob Phillips" wrote:

cLastRow = Cells(Rows.Count,activecell.column).End(xlUp).Row
Cells(cLastRow+1,Activecell.column).FormulaR1C1="= SUM(R1C:R" &

clastrow
& "C)"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JJ" wrote in message
...
How can I sum all cells above a cell. For instance I have spreadsheets
with
varying numbers of rows, and I want to add a sum total at the bottom

of
each
of those columns. Since the number of rows is unknown, I am unsure of

what
to
put after the word "sum"....... Here is the code I have:

ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -2).Select
ActiveCell.FormulaR1C1 = "=SUM(?????????)"






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
Auto Update Text Box Cell Reference jsv Excel Discussion (Misc queries) 0 December 9th 08 09:27 PM
Reference a cell on another sheet and have the information auto up Danielle Excel Worksheet Functions 2 October 9th 08 12:43 AM
Cell Reference: won't auto-calculate, among other things Lillian2611 Excel Worksheet Functions 2 August 14th 07 01:06 AM
Auto fill cell reference Kim K Excel Discussion (Misc queries) 1 July 12th 07 08:36 PM
Sum of 3 nos. into 1 cell in another sheet relevant to specific da Ellie Excel Discussion (Misc queries) 0 September 19th 05 04:57 PM


All times are GMT +1. The time now is 06:38 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"