Excel Macro to Add Value to Cell until Another Cell Value Equals "Stop"

cjohnson0181

New Member
Joined
Mar 29, 2018
Messages
9
All,
I have a spreadsheet setup with formulas to iterate manually and everything is already properly linked. However, sometimes my iterations can go up into the 1000s before meeting my conditions. In short, I need a macro that can make Range("D3") increase in 0.5 increments until the cell value of "L31" equals the word "Stop". I have seen some similar but unfortunately not similar enough to make them work. Any help would be greatly appreciated! I'm sure this is a very simple code which makes it all the more frustrating.

Thanks,
Chase
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
try this:
Code:
Sub test()
Do Until Range("L31") = "Stop"
Range("D3") = Range("D3") + 0.5
Loop


End Sub
 
Upvote 0
Many thanks! It is working very well! I modified the code to stop at 100,000 to prevent the infinite loop that I got myself into. (There isn't infinite solutions to this one!)

Code:
Sub Sweep()

Do Until Range("L31") = "Stop" Or Range("D2") = 100000
Range("D2") = Range("D2") + 0.5
Loop

End Sub
[\Code]
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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