Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Copy Sum formulat to another row

I want to copy a SUM formula from a row that is summing 4 rows of data to
another row where I need it to copy 3 rows of data or 5 rows of data. Is
there a way for the SUM formula to "auto size"?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Copy Sum formulat to another row

Try this:
Sub ProcessData()
Dim LastRow As Long
Dim LastCol As Long

With ActiveSheet

LastRow = .Cells(.Rows.count, "A").End(xlUp).Row
LastCol = .Cells(1, .Columns.count).End(xlToLeft).Column
..Cells(LastRow + 1, "A").Resize(, LastCol).Formula = "=Sum(A1:A" & LastRow &
")"
End With

End Sub

Regards,
Ryan---

--
RyGuy


"Excel Curious" wrote:

I want to copy a SUM formula from a row that is summing 4 rows of data to
another row where I need it to copy 3 rows of data or 5 rows of data. Is
there a way for the SUM formula to "auto size"?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Copy Sum formula to another row

Is there a formula that can accomplish this rather than VBA?

What I want to do is very similar to a subtotal, but without any common item
to subtotal by.

EXAMPLE:
1] 7
2] 5
3] 6
4] <SUM formula here for rows 1-3 RESULT 18
5] 2
6] 8
7] <copy above formula from 4, but have SUM rows 5-6 RESULT 10
8] 3
9] <copy above formula from 4, but have SUM row 8 RESULT 3





"ryguy7272" wrote:

Try this:
Sub ProcessData()
Dim LastRow As Long
Dim LastCol As Long

With ActiveSheet

LastRow = .Cells(.Rows.count, "A").End(xlUp).Row
LastCol = .Cells(1, .Columns.count).End(xlToLeft).Column
.Cells(LastRow + 1, "A").Resize(, LastCol).Formula = "=Sum(A1:A" & LastRow &
")"
End With

End Sub

Regards,
Ryan---

--
RyGuy


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
Copy and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
formulat to convert base 32 to decimal? TMG005 Excel Worksheet Functions 5 July 15th 07 10:31 PM
Translation Formulat Entry Rob Excel Worksheet Functions 0 June 6th 07 02:54 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM


All times are GMT +1. The time now is 08:27 AM.

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"