Can't figure out how to piece it all together - Do Until

Mr_N0body

New Member
Joined
Jul 21, 2021
Messages
3
Office Version
  1. 365
Hi All,
I have some very basic programming experience. Just enough that I usually can find enough of the chunks of code I need to be able to tape and glue it all together to get something running. I'm either out of practice or getting old because I am having a bear of a time getting this one running so I'm hoping someone can help. I keep finding examples that are somewhat related, but dissimilar enough that it is causing issues.

Basically, we have an excel sheet that determines the thickness of a product needed, but it's a guess-and-check setup at the moment. I want to modify the sheet so that it increments the thickness until all the checks are passed. I tried to use a goal seek macro but it finds too many solutions. I need the smallest solution so I want to march it forward from 0. I've attached a screenshot of sample data and the logic I'm trying to create is below.

Do until E27 = 6
If E27 <> 6 add .125 to Increment
If the number of loops > 1000, stop the loops
 

Attachments

  • Capture1.JPG
    Capture1.JPG
    158.9 KB · Views: 11

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Something like this?

VBA Code:
Dim increment As Double, counter As Long

increment = 0
counter = 0

Do Until Sheets("Sheet1").Range("E27") = 6 Or counter = 1000
    'do something
    increment = increment + 0.125
    counter = counter + 1
Loop
 
Upvote 0
Something like this?

VBA Code:
Dim increment As Double, counter As Long

increment = 0
counter = 0

Do Until Sheets("Sheet1").Range("E27") = 6 Or counter = 1000
    'do something
    increment = increment + 0.125
    counter = counter + 1
Loop

That's absolutely beautiful. That gave me enough of a chunk that I can glue and tape in the other pieces I have! Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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