I am running a Do Until loop that is lowering the value in target cells, starting at .99, (x=.99) and then using those values to complete a calculation. I need this loop to stop if 1 of 2 conditions is met.
- Calculated value is within 10% of the target. OR
- x = .75
If the calculation doesn't match the target, the loop will lower x by .005 and try again. But I want .75 to be the lower limit of x.
Do Until
(Workbooks("Group 4 Correlation Solver").Sheets("STRUCTURETOOL").Range("J23").Value * -1 >= Workbooks("Group 4 Correlation Solver").Sheets("STRUCTURETOOL").Range("U28").Value * 0.9 And Workbooks("Group 4 Correlation Solver").Sheets("STRUCTURETOOL").Range("J23").Value * -1 <= Workbooks("Group 4 Correlation Solver").Sheets("STRUCTURETOOL").Range("U28").Value * 1.1) Or (x = 0.75)
Deal_ID = VBA.Right(Workbooks("Weekly Option Update (Master).xlsm").Sheets("GDD Group").Cells(i, "G").Value, 7)
Sheets("Correlation").Range("E7").Value = x
Workbooks("Group 4 Correlation Solver").Sheets("Correlation").Range("F8").Value = x
Workbooks("Group 4 Correlation Solver").Sheets("Correlation").Range("C9").Value = x
Workbooks("Group 4 Correlation Solver").Sheets("Correlation").Range("D10").Value = x
Workbooks("Group 4 Correlation Solver").Sheets("STRUCTURETOOL").Calculate
x = x - 0.005
Workbooks("Weekly Option Update (Master).xlsm").Sheets("GDD Group").Cells(i, "H") = x + 0.005
Loop
My code might not be the most efficient but it does currently run. The issue is that it is not looking at the 2nd condition of the lower limit of x. It simply keeps going until the calculated value is within 10% of the target.
I apologize in advance for the code format. The block right beneath "Do Until" is the code in question with the "and" and "or".