Closed Thread
Results 1 to 9 of 9

Nested Do Until loop with multiple variables

  1. #1
    Registered User
    Join Date
    07-25-2019
    Location
    Application(Earth).Country(USA)
    MS-Off Ver
    v14 32bit
    Posts
    16

    Nested Do Until loop with multiple variables

    Hi, I am a very new user of VBA. I am attempting to nest a loop inside another loop. I am not certain of the correct formatting for nesting the inner loop, and how to declare the variables of the inner loop. I am not certain if a For each loop should be used instead of a Do Until loop for the inner loop.

    I would like for the a b c d variables to increment together as a+1 b+1 c+1 and d-1 with each inner loop cycle.
    I would like to initialize a as 1, b as 1, c as 2, and d as 2 with the ability to change this initialization.
    I would like to print the outcome to Cells(i, 17).


    Thanks in advance for your kind consideration. I would really appreciate any help you may offer. Thank you.



    .bas file attached
    notepad copy of code attached
    spreadsheet before attached
    spreadsheet after attached (runs with my program as shown in the .bas file. Problem is, the program becomes very long and exceeds 64kb and thus I want to loop the repetitive part of it as described in the .bas file)

    Thank you!
    Attached Files Attached Files
    Last edited by tonypizza; 07-29-2019 at 05:53 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2016
    Posts
    6,869

    Re: Nested Do Until loop with multiple variables

    Would you please use code tags? Udit you post and apply these, it's mentioned in the forum rules how to do it.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    07-25-2019
    Location
    Application(Earth).Country(USA)
    MS-Off Ver
    v14 32bit
    Posts
    16

    Re: Nested Do Until loop with multiple variables

    Sorry, I have updated it as requested. Thank you.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2016
    Posts
    6,869

    Re: Nested Do Until loop with multiple variables

    Good.
    Will see if I understand it and if I can help

  5. #5
    Registered User
    Join Date
    07-25-2019
    Location
    Application(Earth).Country(USA)
    MS-Off Ver
    v14 32bit
    Posts
    16

    Re: Nested Do Until loop with multiple variables

    Thank you!

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,682

    Re: Nested Do Until loop with multiple variables

    Can you post an example file to work with.

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Registered User
    Join Date
    07-25-2019
    Location
    Application(Earth).Country(USA)
    MS-Off Ver
    v14 32bit
    Posts
    16

    Re: Nested Do Until loop with multiple variables

    Hi, I've attached the requested files in the original post as requested. Thank you for your help!

  8. #8
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    28,336

    Re: Nested Do Until loop with multiple variables

    The OP has requested this thread be deleted since he wants to start the same one in the Commercial Service Forum.

    We don't as a rule delete theads so I've decided to leave it here but close it for further postings.
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 2000/3/7/10/13/16
    Posts
    51,076

    Re: Nested Do Until loop with multiple variables

    Agreed, Richard, thanks for taking care of this.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Define multiple variables with loop
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2016, 03:33 PM
  2. [SOLVED] Multiple Variables in For Each Loop
    By Excel Guy 123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-16-2014, 11:47 PM
  3. Replies: 1
    Last Post: 05-12-2014, 10:25 PM
  4. Nested For Each loop for 2 range variables
    By artur.serra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 10:34 AM
  5. [SOLVED] Nested FOR loop from multiple FOR loops
    By Chilton in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 08-15-2012, 11:36 AM
  6. Sum multiple nested loop entries
    By dems in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2010, 09:09 AM
  7. For each loop nested; getting stuck on one cell in first iteration of nested loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2009, 11:54 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