UDF For Each to end after certain range

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
686
Office Version
  1. 365
Platform
  1. Windows
I was thankful enough to receive a UDF from Rick Rothstein. https://www.mrexcel.com/forum/excel...-not-blank-again-post5294214.html#post5294214

I was wondering if someone can help me and figure out a Do Until a certain range, I have to uses over 30 of these functions in one sheet and it calculates very very slow.

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

Thanks
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Maybe
Code:
Function SumToYes()
  Dim R As Long
  R = Application.Caller.Row + 1
  Do While Cells(R, "B").Value <> "yes"
    If Cells(R, "A") = "" Then Exit Do
    SumToYes = SumToYes + Val(Cells(R, "A").Value)
    R = R + 1
  Loop
End Function
This will exit when col A is blank
 
Upvote 0
Thank you Fluff! I am going to try this now.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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