×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

why don't these loops work?

why don't these loops work?

why don't these loops work?

(OP)
Sub zerotest()
   Dim seekValue As Double
   Dim changeCell As Range
   Inflation = Range("O7").Value
   seekValue = 12345
   'seekValue = InputBox("What's the value to seek?")
   For Each changeCell In Range("N14:N32").Cells
          'Do Until changeCell < 10
           changeCell.GoalSeek Goal:=seekValue, changingCell:=changeCell.Offset(0, -4)
             'Do Until changeCell < 10
            ' Loop
                seekValue = seekValue + (seekValue * Inflation)
               ' Loop
                Next changeCell
End Sub
yes i know they are commented out.
but how do i limit the value to 10 or more?
thanks

RE: why don't these loops work?

Why don't you use a for loop? something like :

For changeCell = 1 To 10
   changeCell.GoalSeek Goal:=seekValue,       changingCell:=changeCell.Offset(0, -4)
   seekValue = seekValue + (seekValue * Inflation)
End For

Cyril Guichard
Defense Program Manager
Belgium

RE: why don't these loops work?

What you have put in your code

Do Until changeCell < 10

is saying do the code until the value of changeCell is less than 10.

Try

Do Until changeCell > 10

RE: why don't these loops work?

Or

CODE

do while changeCell < 10

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources