Copy Sum formulat to another row

  • Thread starter Thread starter Excel Curious
  • Start date Start date
E

Excel Curious

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"?
 
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---
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top