+ Reply to Thread
Results 1 to 6 of 6

'Do While' doesn't check for status until it loops?

  1. #1
    Registered User
    Join Date
    08-09-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    39

    'Do While' doesn't check for status until it loops?

    I have a simple distribution code that distributes product to different places based on a changing percentage. It has to be in whole numbers so there is always a small remainder by rounding down. To distribute the remainder evenly I want to go down the list and just +1 each place until the remainder is gone. I have this:

    Please Login or Register  to view this content.
    This does what I want but only checks the remainder total on loop. If it is 3, it works fine. If it is 2, it adds 3(1/1/1). If it is 4, it will add 3, loop, then add another 3.

    How can I get the Do While to check the total of the remainder after every If>Then instead of after the loop?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 'Do While' doesn't check for status until it loops?

    This is where the remainder is checked,
    Please Login or Register  to view this content.
    it isn't checked here.
    Please Login or Register  to view this content.
    If it appears the other way round then there could be something else going on.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-09-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: 'Do While' doesn't check for status until it loops?

    Thanks for the info. All I noticed is that it only checks once each loop rather than when I subtract 1. Am I able to rectify this or is that just not how it works? If not what syntax should I be using?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: 'Do While' doesn't check for status until it loops?

    Three places:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    08-09-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: 'Do While' doesn't check for status until it loops?

    Yep that'd do it. Duh! Of course a failed exit check will update the tally.. as opposed to actually modifying the tally. (The salt is real haha.)

    Thanks a bunch!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: 'Do While' doesn't check for status until it loops?

    You're welcome.

+ 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] Why doesn't status bar update consistently?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 11-08-2015, 06:32 PM
  2. Replies: 3
    Last Post: 09-11-2014, 04:32 PM
  3. Replies: 4
    Last Post: 04-08-2012, 09:43 PM
  4. [SOLVED] My Excel 2007 doesn't have a status bar, pls show me how?
    By InDistressWithExcel in forum Excel General
    Replies: 1
    Last Post: 08-17-2006, 04:15 PM
  5. [SOLVED] Why doesn't status bar update consistently?
    By amazingm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2006, 10:30 AM
  6. [SOLVED] On status bar, sum of selected cells doesn't automatically appear.
    By Chozzie in forum Excel General
    Replies: 2
    Last Post: 11-13-2005, 10:10 PM
  7. Check Box Status
    By Tom in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2005, 10:06 AM

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