Results 1 to 3 of 3

Can't get nested Loop to copy range values from 2 tables working correctly

Threaded View

gtol Can't get nested Loop to copy... 04-05-2013, 11:23 AM
StephenR Re: Can't get nested Loop to... 04-05-2013, 11:41 AM
gtol Re: Can't get nested Loop to... 04-05-2013, 12:01 PM
  1. #1
    Registered User
    Join Date
    02-13-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    22

    Can't get nested Loop to copy range values from 2 tables working correctly

    Hi,

    I am working on a VBA application and I have encountered a situation that needs a nested loop to copy values from 2 tables (Departments and Roles) from a Source sheet to a Destination sheet.

    The copy operation needs to show all possible combinations of Department and Role that can exist as illustrated below :

    Departments
    A
    B
    C

    Roles
    1
    2
    3

    Required result (9 possible combinations):

    A1
    A2
    A3
    B1
    B2
    B3
    C1
    C2
    C3

    I know we will need a nested loop here that goes through both tables sequentially using an inner and outer loop but I can't figure out the correct syntax to get this working. I have seached the forum but the examles I found were very complex and I couldn't amend the code to achieve the desired result without getting lots of errors.

    I am attaching a spreradsheet to better illustrate what is required. I have also created the bare bones of a procedure for the loop.

    I am hoping that there is some VBA guru out there who can help !!

    Many thanks in advance,


    GTOL
    Attached Files Attached Files

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