UDF to sum until certain column is not blank again

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
686
Office Version
  1. 365
Platform
  1. Windows
Is there a UDF that someone can think of that can sum the column "A" UNTIL column "B" says "Yes" again and put the formula in column C?

I have seen similar UDFs but I cannot wrap my head around this one.
[TABLE="width: 246"]
<colgroup><col span="3"></colgroup><tbody>[TR]
[TD] [/TD]
[TD]Yes[/TD]
[TD] $ 1.76[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.76[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.12[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.76[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.12[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.01[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ - [/TD]
[TD]Yes[/TD]
[TD] $ 3.28[/TD]
[/TR]
[TR]
[TD] $ - [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.76[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.12[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 2.28[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.12[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.01[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ - [/TD]
[TD]Yes[/TD]
[TD] $ 1.76[/TD]
[/TR]
[TR]
[TD] $ - [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.76[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.12[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.76[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.12[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ 0.01[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] $ - [/TD]
[TD]Yes[/TD]
[TD] $ 3.28[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I am not sure why, but you example totals each are $0.01 too small. Anyway, give the following UDF a try...
Code:
Function SumToYes()
  Dim R As Long
  R = Application.Caller.Row + 1
  Do While Cells(R, "B").Value <> "Yes"
    SumToYes = SumToYes + Val(Cells(R, "A").Value)
    R = R + 1
  Loop
End Function
 
Upvote 0
Hi Rick,

Thank you for this UDF! I am very new to UDFs, so how how i type this in the cell?

Thanks!
 
Upvote 0
Hi Rick,

i just entered that with nothing else in it and it worked.

Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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