+ Reply to Thread
Results 1 to 8 of 8

Loop range copy based on previous column

  1. #1
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Loop range copy based on previous column

    I want to copy what's on D column and stop from the last row of column A and paste it on column F. I already tried this code, but its not working. i don't know what am i missing.?



    Please Login or Register  to view this content.
    Thanks for the usual help!
    Last edited by darkhangelsk; 03-12-2014 at 01:10 PM.

  2. #2
    Registered User
    Join Date
    04-13-2013
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    17

    Re: Loop range copy based on previous column

    "Not working" covers a lot of ground. Are you getting an error, or what?

    (It looks like you are mixing up the two last row vars, BTW) Better to use longer, more descriptive names.

    "LastRowOfColumnA" for example.

  3. #3
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Re: Loop range copy based on previous column

    I didn't get an error. but nothing is happening. However if i removed "& Last_Row" from "Range("D2").Resize(lastrow).Copy Range("F2" & Last_Row)",

    i get the copy of what's on the column D but it's not looping until the last row of column A.

  4. #4
    Registered User
    Join Date
    04-13-2013
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    17

    Re: Loop range copy based on previous column

    I think using Range("F2" & LastRow) might be throwing you off. Maybe try something like this?

    Please Login or Register  to view this content.
    Last edited by Quixologies; 03-12-2014 at 01:51 PM. Reason: Added comments to code

  5. #5
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Re: Loop range copy based on previous column

    You're almost there Quixologies! just need to fill the column F until the last row of column A... i attached sample data for you for better understanding
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Re: Loop range copy based on previous column

    I'm really trying, hehe... maybe this code might help, but still not my desired result.

    Please Login or Register  to view this content.
    the only lacking is that its not pasting the data (data from D2 until last row) to column F until the last row of column A.

  7. #7
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Re: Loop range copy based on previous column

    I'm thinking of this:

    Please Login or Register  to view this content.
    but still can't get it to work...

  8. #8
    Registered User
    Join Date
    04-13-2013
    Location
    USA
    MS-Off Ver
    Excel 2000
    Posts
    17

    Re: Loop range copy based on previous column

    So you aren't just copying, you're doing some sort of autofill based on a pattern.

    Looks like you're stuck looping over the range somehow.

    First you need to obtain the number of rows in your pattern in column D.

    Then you'd simply loop over the number of rows of data in A with a step-counter equal to the length of your pattern.

    Each time through the loop you'd copy the contents of the range holding your pattern to the next set of rows in Column F

    You'll have to use MOD to get any remainder figured out for the last portion of the pattern (if it doesn't divide evenly)

    I don't have time to come up with the code for that right now, though! Sorry!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 08-13-2013, 09:44 AM
  2. [SOLVED] loop through certain ranges and put down specific text based on previous cell with data
    By liz5818 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2013, 01:43 PM
  3. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  4. Copy and Paste Loop based on corresponding value in another column
    By gibby8 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2011, 03:25 PM
  5. Copy dynamic range from previous sheet and paste after last used row in a range
    By Mistweaver in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-04-2010, 06:24 PM

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