Decreasing Do Until loop

robbie95

New Member
Joined
Mar 3, 2016
Messages
2
Hi guys,
I'm pretty new to coding but I need it for a dissertation on auctions. Any help is greatly appreciated!!

A simplified version of what I am trying to achieve is to have a blank excel file with the number 10 in A1. I then want to run a Do Until loop with "A1 - 1" until it gets to zero, and post the result in cell B1. I can't do it with a counter as in my actual problem (second code) the value I need depends on when a solution changes. My attempt so far:

Code:
Sub Practiseloop()
Dim i As Integer
i = 0
Do Until Range("A1").Value = 0
A1 = A1 - (1 * i)
Debug.Print i
Loop
End Sub

I know this is a very simplified version but it should fix the code below!

Code:
Sub SuppFirstPriceOpenSolve()Dim i As Integer
i = 0
'keep going round the loop until the condition is true


Do Until Range("J24").Value = 0
I24 = I24 - (1000 * i)
    Range("J2: J278").Value = 0
    SolverReset
    SolverAdd CellRef:="$J$2:$J$278", Relation:=1, FormulaText:="1"
    SolverAdd CellRef:="$J$2:$J$278", Relation:=3, FormulaText:="0"
    SolverAdd CellRef:="$L$2:$L$8", Relation:=1, FormulaText:="$M$2:$M$8"
    SolverAdd CellRef:="$L$2:$L$8", Relation:=3, FormulaText:="0"
    SolverAdd CellRef:="$O$2:$T$2", Relation:=1, FormulaText:="$O$6:$T$6"
    SolverOk SetCell:="$O$8", MaxMinVal:=1, ValueOf:=0, ByChange:="$J$2:$J$278"
    SolverAdd CellRef:="$J$2:$J$278", Relation:=4, FormulaText:="integer"
    RunOpenSolver
Debug.Print i
Loop
End Sub
Thanks again,
Robbie
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Thanks for the reply but later on I will have to do
A1 = A1 - (1000*i)
So I left it in the same format

My issue is that it the code does not work as intended
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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