Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Setting a sum formula

I have the following code:

Set EndRow = TargetSheet.Range("A1", TargetSheet.Range("A65536").End
(xlUp).Address)
ListRow = EndRow.Row + EndRow.Rows.Count

What I am trying to do is determine the last row of data on a sheet, go to
the cell right below it, and sum up everything above it. The number of rows
will always be different. Please help. Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Setting a sum formula

Hi

That's what R1C1 does. This will sum "everything above it" just anywhere as
long as it's not in row 1:

ActiveCell.FormulaR1C1 = "=SUM(R1C1:R[-1]C)"

replace "Activecell" with whatever addressing system you use. Do not
activate.

HTH. Best wishes Harald

"Mike" skrev i melding
...
I have the following code:

Set EndRow = TargetSheet.Range("A1", TargetSheet.Range("A65536").End
(xlUp).Address)
ListRow = EndRow.Row + EndRow.Rows.Count

What I am trying to do is determine the last row of data on a sheet, go to
the cell right below it, and sum up everything above it. The number of

rows
will always be different. Please help. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Setting a sum formula

Ooops. Sorry, typo. Should read:

ActiveCell.FormulaR1C1 = "=SUM(R1C:R[-1]C)"


"Harald Staff" skrev i melding
...
Hi

That's what R1C1 does. This will sum "everything above it" just anywhere

as
long as it's not in row 1:

ActiveCell.FormulaR1C1 = "=SUM(R1C1:R[-1]C)"

replace "Activecell" with whatever addressing system you use. Do not
activate.

HTH. Best wishes Harald

"Mike" skrev i melding
...
I have the following code:

Set EndRow = TargetSheet.Range("A1", TargetSheet.Range("A65536").End
(xlUp).Address)
ListRow = EndRow.Row + EndRow.Rows.Count

What I am trying to do is determine the last row of data on a sheet, go

to
the cell right below it, and sum up everything above it. The number of

rows
will always be different. Please help. Thanks.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Setting a sum formula

Try this

EndRow = TargetSheet.Range("A" & Rows.Count).End(xlUp).Row
If EndRow 1 Or Range("A1").Value < "" Then
Cels(EndRow+1, "A").Formula = "=SUM(A1:A" & EndCell.Row & ")"
End If

--

HTH

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


"Mike" wrote in message
...
I have the following code:

Set EndRow = TargetSheet.Range("A1", TargetSheet.Range("A65536").End
(xlUp).Address)
ListRow = EndRow.Row + EndRow.Rows.Count

What I am trying to do is determine the last row of data on a sheet, go to
the cell right below it, and sum up everything above it. The number of

rows
will always be different. Please help. Thanks.



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
Help with setting up a formula Greggo G[_2_] Excel Discussion (Misc queries) 2 November 25th 09 02:02 PM
Help with setting a formula HankL New Users to Excel 1 June 14th 08 05:05 PM
Setting up a formula fishingforhelp Excel Worksheet Functions 4 May 3rd 07 09:52 AM
cancelling getpivot formula when setting formula outside pivot ta. cancelling getpivot formula Excel Worksheet Functions 2 October 31st 06 10:31 PM
Setting up a formula TArbuckle Excel Programming 1 August 30th 04 10:42 PM


All times are GMT +1. The time now is 09:55 PM.

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

About Us

"It's about Microsoft Excel"