+ Reply to Thread
Results 1 to 5 of 5

Creating a macros to copy and paste a dynamic range based on certain strings in cells.

  1. #1
    Registered User
    Join Date
    11-25-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    31

    Creating a macros to copy and paste a dynamic range based on certain strings in cells.

    Hi

    I could use a little help with developing a macros for copying a dynamic range of data in a long data base of information.

    In the attached excel file in sheet one, I want to take the range that begins with the name up to the summary at the bottom, and do this throughout the range.

    Every cell that includes an individuals name includes a constant string "YUL"

    I want the macros to go through column "B" for each cell if the cell contains the value "YUL" I want it copy the range up to the next string that contains "YUL".

    In the example I provided, I would like to copy from A1:G29, then B30:G62, then A63:G90, etc, etc

    So the function uses column B as the reference for "YUL" and selects the corresponding range starting from Column A and finds the next "YUL" value in cell B30, but I want the range up to the row before the next "YUL" value copied, so not A1:G30 but G29.

    I'll keep searching for a quick solution in the mean time.

    Thanks!
    Attached Files Attached Files
    Last edited by hkayani08; 03-09-2012 at 10:54 AM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Creating a macros to copy and paste a dynamic range based on certain strings in cells.

    Hi

    You don't actually say where you want the copy section put so I've not done anything with the copied range.

    Please Login or Register  to view this content.
    rylo

  3. #3
    Registered User
    Join Date
    11-25-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Creating a macros to copy and paste a dynamic range based on certain strings in cells.

    Thank you Rylo, you're a gentleman!

    I only have one problem remaining, in that it does not loop over to the next set of ranges. It only stops at the first range.

    I integrated the macros with the attached sheet so you can see what I mean. How my macros works is described below. My issue is that after the first range of data A1:G28, it stops.


    Code:

    Please Login or Register  to view this content.
    After the first loop through, the macros stops.

    If anyone can help, it would be appreciated.

    Thanks!
    Attached Files Attached Files
    Last edited by hkayani08; 03-09-2012 at 10:17 AM.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Creating a macros to copy and paste a dynamic range based on certain strings in cells.

    Hi

    You are not moving back to the raw data yul sheet after the first set of actions for it to be on the right sheet to continue the copy / paste actions. So make sure you put something into the
    Please Login or Register  to view this content.
    section to move back to the right sheet.

    Also, I notice that the last item in column B of the data sheet is a cell with the value YUL. I don't know if this is a result of cutting down the example file for testing or part of the real data, but that cell will have to be cleared out for this to action.

    Finally, can you please edit post #3 and make sure you put code tags around the code.

    rylo

  5. #5
    Registered User
    Join Date
    11-25-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Creating a macros to copy and paste a dynamic range based on certain strings in cells.

    Thanks,

    works like a charm.

    All I had to add after "Call Delete" is "Sheets("Raw Data YUL").Select"

    This saves alot of time for me, I appreciate your help.

+ 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