+ Reply to Thread
Results 1 to 4 of 4

mixture of do while and for loops

Hybrid View

  1. #1
    Registered User
    Join Date
    06-22-2011
    Location
    ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    mixture of do while and for loops

    hi im having a bit of problem finding what do while and for loops ive to use to get this code running, basically i have numbers in column 1, first one is around 15000, and there are multiple entries (not all the same) for each one, i want for all the numbers 15000-15007 to return 1, 15008-150014 to return 2, then when the loop gets to 52 it goes back to 1, again,
    anyone any ideas on the loops?
    thanks

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: mixture of do while and for loops

    Don't quite follow, can you post a sample workbook showing the layout and expected result?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    06-22-2011
    Location
    ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: mixture of do while and for loops

    Book1.xlsx


    so its just basically that,

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,849

    Re: mixture of do while and for loops

    Your description above does not match your example. In your description you said that 15000-15007 returns 1, but in your example 15007 returns 2. In your original description the first block 15000-15007 contains 8 numbers and the second block 15008-15014 contains 7 numbers. The point at which you turn around and restart at 1 is 15365. I assumed this was an error and you are working with groups of 7, starting at 15001. (Maybe you are trying to get week numbers from this since you are restarting after reaching 52.)

    I have attached an example that does this with a formula and no VBA. Even if my assumption is wrong, this should give you the idea of how this can be done.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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