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.
Yes $ 1.76
$ 0.76
$ 0.12
$ 0.76
$ 0.12
$ 0.01
$ - Yes $ 3.28
$ -
$ 0.76
$ 0.12
$ 2.28
$ 0.12
$ 0.01
$ - Yes $ 1.76
$ -
$ 0.76
$ 0.12
$ 0.76
$ 0.12
$ 0.01
$ - Yes $ 3.28

<colgroup><col span="3"></colgroup><tbody>
</tbody>
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,213,534
Messages
6,114,184
Members
448,554
Latest member
Gleisner2

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