+ Reply to Thread
Results 1 to 6 of 6

Loop or For Each within a For Each

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Loop or For Each within a For Each

    I am having some technical difficulties trying to place data onto sheet2. Sheet2 starts out blank, as sheet1 is proccessed it pastes data to sheet2. I have tried a "For Each" that failed only pasting data into Range "A1" for every found instance.

    In the code below, the area colored "Magenta", I need a Loop of some type that as data is pasted into column A on sheet2, it indexes to the next available cell and continues.
    How do I construct such a Loop or For Each with in the existing For Each?
    Please Login or Register  to view this content.
    Any hints, tips or examples are welcome.
    Last edited by Rick_Stanich; 01-22-2010 at 12:56 PM.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Loop or For Each within a For Each

    It's not clear from code alone what is suppose to happen.
    Can you create small test workbook with before and after records.

    guessing....
    Should Sh2Range be a range of cells? Perhaps it should be just the next single cell at the end of any existing data. Then you would simply set the reference to the next cell below by using the OFFSET method.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Loop or For Each within a For Each

    No animals have been harmed in the making of this macro!

    In the macro, enable this line to see what data is found on sheet 1.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Rick_Stanich; 01-22-2010 at 12:36 PM.

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Loop or For Each within a For Each

    Edit:
    I forgot the macro is workbook name sensitive.
    in the macro change:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Loop or For Each within a For Each

    I guessed right,

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Loop or For Each within a For Each

    How the heck do you guys (gals) do this? LOL
    You make it seem simple with the methods you use.

    I see the loop need not be within the"For Each" as I thought.

    Thank you!

    My last humbling attempt. Which only resulted in the last entry (49) being pasted to sheet2 for all 9 total values found. (Just so you know I was working on it.)
    Please Login or Register  to view this content.
    Just ignor my code, it may cause brain damage.
    Last edited by Rick_Stanich; 01-22-2010 at 12:56 PM.

+ 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