UDF to sum until certain column is not blank again

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
543
Office Version
365
Platform
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>
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,043
Office Version
2010
Platform
Windows
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
 

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
543
Office Version
365
Platform
Windows
Hi Rick,

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

Thanks!
 

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
543
Office Version
365
Platform
Windows
Hi Rick,

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

Thank you so much!
 

Watch MrExcel Video

Forum statistics

Threads
1,102,593
Messages
5,487,749
Members
407,609
Latest member
Chrissie1970

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top