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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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