ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   insert sum when first blank cell found (https://www.excelbanter.com/excel-programming/390419-insert-sum-when-first-blank-cell-found.html)

[email protected][_2_]

insert sum when first blank cell found
 
I have data in a worksheet.

I have two rows between each of my lines of data.

What I need is a macro to insert a sum calculation for everything
above until the last sum calculation. The numbers are contained in
column A

I hope this makes sense.

Thanks

Andrea


joel

insert sum when first blank cell found
 
You have something like this

1 5
2 6
3 =sum(a1:a2)
4
5 7
6 8
7 =sum(A3:a6)
8
9 35
10 36
11 =sum(a7:a10)

if you copy =sum(a3:a6) and past it in all the first blank rows it will
automatically increment to meet your requirements.

" wrote:

I have data in a worksheet.

I have two rows between each of my lines of data.

What I need is a macro to insert a sum calculation for everything
above until the last sum calculation. The numbers are contained in
column A

I hope this makes sense.

Thanks

Andrea



[email protected][_2_]

insert sum when first blank cell found
 
I wanted a macro to do this automatically.....


Rather than me do it manually.....


Thanks

Andrea


On 31 May, 12:49, Joel wrote:
You have something like this

1 5
2 6
3 =sum(a1:a2)
4
5 7
6 8
7 =sum(A3:a6)
8
9 35
10 36
11 =sum(a7:a10)

if you copy =sum(a3:a6) and past it in all the first blank rows it will
automatically increment to meet your requirements.



" wrote:
I have data in a worksheet.


I have two rows between each of my lines of data.


What I need is a macro to insert a sum calculation for everything
above until the last sum calculation. The numbers are contained in
column A


I hope this makes sense.


Thanks


Andrea- Hide quoted text -


- Show quoted text -




joel

insert sum when first blank cell found
 
Try this

Sub copysum()

EndRow = Cells(Rows.Count, "A").End(xlUp).Row

FirstRow = 1
RowCount = 1
Do While RowCount <= EndRow + 1

If IsEmpty(Cells(RowCount, "A")) Then

LastRow = RowCount - 1
Cells(RowCount, "A").FormulaR1C1 = _
"=SUM(R" & CStr(FirstRow) & "C1:R" & _
CStr(LastRow) & "C1)"

FirstRow = RowCount
RowCount = RowCount + 1

End If

RowCount = RowCount + 1
Loop

End Sub


" wrote:

I wanted a macro to do this automatically.....


Rather than me do it manually.....


Thanks

Andrea


On 31 May, 12:49, Joel wrote:
You have something like this

1 5
2 6
3 =sum(a1:a2)
4
5 7
6 8
7 =sum(A3:a6)
8
9 35
10 36
11 =sum(a7:a10)

if you copy =sum(a3:a6) and past it in all the first blank rows it will
automatically increment to meet your requirements.



" wrote:
I have data in a worksheet.


I have two rows between each of my lines of data.


What I need is a macro to insert a sum calculation for everything
above until the last sum calculation. The numbers are contained in
column A


I hope this makes sense.


Thanks


Andrea- Hide quoted text -


- Show quoted text -






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com