+ Reply to Thread
Results 1 to 5 of 5

copy, paste and loop

  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    Lancaster, PA
    MS-Off Ver
    Excel 2003
    Posts
    8

    copy, paste and loop

    Good afternoon,
    I need help copying from an offset column and then filling down. I know how many columns I have but the number of rows will vary so I can't set up a specific range.

    My column names are A, B & C. As long as there is data in Column A, I need to copy the contents of cell B3 and paste it into cells C3, C4 and C5. But when the text in Column B changes, or when the first 8 digits in Column A change, I need the information in the adjacent B cell to be copied and pasted instead until the next change.

    Please see the attached spreadsheet. I have given an example of what I have and what I want it to look like.
    Thanks!
    Attached Files Attached Files
    Last edited by zinoviia660; 07-09-2010 at 11:57 AM.

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

    Re: copy, paste and loop

    Put this formula in C3 and copy down:

    =IF(LEFT(A3,8)=LEFT(A2,8),C2,B3)
    _________________
    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!)

  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: copy, paste and loop

    The same solution in macro format:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-25-2010
    Location
    Lancaster, PA
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: copy, paste and loop

    Thank you so much for both solutions! The formula helped me understand the code.

    The only thing I needed to change was
    With Range("C2:C" & LR) .......changed to..... With Range("C3:C" & LR)
    Otherwise, my the column header gets changed, too.

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

    Re: copy, paste and loop

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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