+ Reply to Thread
Results 1 to 3 of 3

Help with a Do While loop

  1. #1
    Registered User
    Join Date
    11-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Help with a Do While loop

    First off, thanks to everyone ahead of time for helping me with this. I need help with a Do While loop that I am creating. First, let me give the background on what I am trying to accomplish.

    I need a loop that will look at a budget and continue to loop until that available (or remaining) budget is gone. In doing so, this loop will need to find the greatest index in a range of cells and then add "1" to the number in the cell directly to the right of it. I have staged out an example of the first three steps manually in the attached excel file.

    Below is the code that I have written so far:

    __________________________________________________

    Sub Model_Run()

    Application.ScreenUpdating = False

    Range("H3:H12").Formula = 1

    Dim budget_monitor As Integer

    budget_monitor = Cells(18, 6)

    Do While budget_monitor >= 0.01

    If budget_monitor = 0 Then
    Exit Do

    Else

    End If

    Loop

    Application.ScreenUpdating = True

    End Sub

    _______________________________________________

    First, the command to set all cells in the range "purchase" to "1" is important. All items must be bought, what is trying to be solved here is finding the most cost efficient combination given the item's cost and associated quantities. Second, there is a cell that has been written to keep track of the remaining budget. In the non example file I have going, that cell is "F18".

    Feel absolutely free to rewrite any code that I have already written if there is a better way to do. I am trying to learn as I go with VBA.

    Again, ANY and all help is very greatly appreciated. I look forward to hearing back from you all!
    Attached Files Attached Files
    Last edited by warrinerjr; 11-20-2013 at 11:58 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Help with a Do While loop

    Please Login or Register  to view this content.
    ?

  3. #3
    Registered User
    Join Date
    11-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Help with a Do While loop

    That worked! Thank you so much for your help again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  2. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  3. Macro Loop Broken. Detects Max but doesn't continue loop
    By herchenbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2011, 12:17 PM
  4. Replies: 0
    Last Post: 07-20-2010, 11:42 AM
  5. Loop a column on Sheet1 and loop a row on Sheet2 to find a match
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-13-2009, 02:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1