+ Reply to Thread
Results 1 to 5 of 5

Nested loop to concatenate 2 columns of data

  1. #1
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Nested loop to concatenate 2 columns of data

    Hi,

    I think I just need a basic Nested For Loop code...

    I have a list of in column A, from A1:A537

    and another list in column B, for B1:B50

    I want to add a column that concatenates,

    each item in Column A to B1 (so 537 rows), then again each item in Column A to B2, another 537 rows, etc.. this loop is repeated 50 times, one for each name in column B.
    Last edited by JohnnyBGood; 10-27-2009 at 09:12 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Nested loop to concatenate 2 columns of data

    Hello JohnnyBGood,

    Here is a macro you can use. It uses column "C" as the helper column.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Nested loop to concatenate 2 columns of data

    There is no need for a loop
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Nested loop to concatenate 2 columns of data

    Thanks very much guys...

    Leith, I was close to yours, except that N=N+1 part....

    I couldn't figure out how to go past row 537 to keep adding fields.

  5. #5
    Registered User
    Join Date
    12-30-2011
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Nested loop to concatenate 2 columns of data

    dear friends i was searching for concatenating column with row data
    i found this thread i have a different proposition
    i have values in coloumn a and row 2 (these are all in sheet1)
    i need these values to be concatenated in the following manner in sheet 2
    sheet2A2=sheet1(a2,b2)
    sheet2A3=sheet1(a2,c2)
    sheet2A4=sheet1(a2,d2)
    sheet2A5=sheet1(a2,e2)

    until it finds the empty cell in row 2
    then it has to loop for A3 then A4 etc

    regards
    pvr

+ 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