Hopefully easy sum macro

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
529
Office Version
  1. 365
Platform
  1. Windows
Hi Guys

I have a list of data - dates in column A, Names in column B and scores in column C

I need to run a macro that looks in column A until it finds a Blank cell, then moves to column C and performs an autosum on however many values there are, and then repeat for every blank cell it finds in column A until it finds 2 blank cells in a row and then it could stop.

Is this possible?

thanks

Neil
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I assumed data start at row 2.
Try this:
Code:
[FONT=lucida console][COLOR=Royalblue]Sub[/COLOR] a1108887a()
[I][COLOR=seagreen]'https://www.mrexcel.com/forum/excel-questions/1108887-hopefully-easy-sum-macro.html[/COLOR][/I]
[COLOR=Royalblue]Dim[/COLOR] i [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
[COLOR=Royalblue]Dim[/COLOR] flag [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Boolean[/COLOR]

flag = [COLOR=Royalblue]False[/COLOR]
i = [COLOR=crimson]2[/COLOR]
    [COLOR=Royalblue]Do[/COLOR]
        [COLOR=Royalblue]If[/COLOR] flag = [COLOR=Royalblue]False[/COLOR] [COLOR=Royalblue]Then[/COLOR] z = i: flag = [COLOR=Royalblue]True[/COLOR]
            [COLOR=Royalblue]If[/COLOR] Cells(i, [COLOR=brown]"A"[/COLOR]) = [COLOR=brown]""[/COLOR] [COLOR=Royalblue]Then[/COLOR]
                Cells(i, [COLOR=brown]"C"[/COLOR]) = WorksheetFunction.Sum(Range([COLOR=brown]"C"[/COLOR] & z & [COLOR=brown]":C"[/COLOR] & i - [COLOR=crimson]1[/COLOR]))
                flag = [COLOR=Royalblue]False[/COLOR]
            [COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
        i = i + [COLOR=crimson]1[/COLOR]
    [COLOR=Royalblue]Loop[/COLOR] [COLOR=Royalblue]Until[/COLOR] Cells(i - [COLOR=crimson]1[/COLOR], [COLOR=brown]"A"[/COLOR]) = [COLOR=brown]""[/COLOR] [COLOR=Royalblue]And[/COLOR] Cells(i, [COLOR=brown]"A"[/COLOR]) = [COLOR=brown]""[/COLOR]

[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]
 
Upvote 0
Perhaps:
Code:
Sub v()
Dim a As Range
On Error Resume Next
For Each a In Range("C2:C" & Cells(Rows.Count, "A").End(3).Row).SpecialCells(xlCellTypeConstants).Areas
    a(a.Count + 1).Value = WorksheetFunction.Sum(Range(a(1), a(a.Count)))
Next
On Error GoTo 0
End Sub
 
Upvote 0
Similar to footoo but looks at column A, for blank cells
Code:
Sub neilp()
   Dim Rng As Range
   For Each Rng In Range("A2", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Offset(, 2).Areas
      Rng.Offset(Rng.Count).Resize(1).Value = Application.Sum(Rng)
   Next Rng
End Sub
 
Upvote 0
Thanks Guys.

I used Akuini's method and it seems to be working perfectly :)

Thanks again

Neil
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top