Do Until

Keith.Jackson

Board Regular
Joined
Mar 31, 2005
Messages
115
I want to run a "Do Until" procedure on a range of values. I am having trouble with the first part.
I want to pick From 20 cells Sheets("Sheet2").Range ("D1:D20")
and run the procedure after picking each value in order from top to bottom.
How do I write the code to pick the first value in the range , run the Do Until and then pick the next value in the range until the value = 0?

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.
You can place your Do Loop inside a For Each Loop
For e.g.,

For Each c In Range("D1:D20")
Do Untill

Loop

Next C
 
Upvote 0
How do I make the loop stop. If I make C=0 the loop doesn't run. If I make it equal to anything else, it keeps on running.
 
Upvote 0
Can we see your current code?

And can you explain the actual purpose of the code?
 
Upvote 0
Sub Send()
Do Until C = 0
For Each C In Sheets("Sheet2").Range("D2:D20")

Sheets("Sheet2").Range("C34").Value = C
Next C
Loop

End Sub
 
Upvote 0
After the value is copied to Sheet2 range C34, there is another procedure in the loop, but I have to make the loop stop befor I put the other procedure in.
 
Upvote 0
Instead of using Do Until, you can use a For Loop and an Exit for.

For e.g.,

For Each C In Sheets("Sheet2").Range("D2:D20")
Sheets("Sheet2").Range("C34").Value = C
If c = 0 Then Exit For
Next C
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

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