+ Reply to Thread
Results 1 to 5 of 5

For Each Loops and copying cells next to c.Value

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Question For Each Loops and copying cells next to c.Value

    Hi all, first I'll submit my code and then the problem.

    Please Login or Register  to view this content.
    The logic behind this is supposed to be:

    1. For each value in one worksheet (LookTbl), find the corresponding value in another worksheet (IndMthly (2)).
    2. When found, copy the values in the range from LookTble and paste them into their proper cells in IndMthly (2).

    The first iteration happens successfully. However, when the second iteration occurs, the range to copy goes back to the first iteration's data range.

    How do I select the cells for Next c when it stays on the first c's row. Sorry if this is confusing but I am confused. If more is needed please let me know.

    Thanks
    Attached Files Attached Files
    Last edited by Mordred; 07-21-2010 at 04:38 PM. Reason: Uploading a file

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: For Each Loops and copying cells next to c.Value

    Please note that there are lines in the code that don't need to be there. I've been trying to figure this out on my own for a couple of days now, to no avail.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: For Each Loops and copying cells next to c.Value

    Post an example workbook demonstrating BEFORE/AFTER so we can see what the macro is supposed to accomplish.
    Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: For Each Loops and copying cells next to c.Value

    I hope that this will do.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: For Each Loops and copying cells next to c.Value

    Well, I have this so far:

    Please Login or Register  to view this content.
    This works if a.Value = c.Value but if it doesn't, I receive a run time error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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