+ Reply to Thread
Results 1 to 6 of 6

Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

  1. #1
    Registered User
    Join Date
    05-16-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2011
    Posts
    6

    Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

    [EDIT] Completely new text ahead

    Hey guys,

    I posted about this before, but I went into a long-winded confusing explanation and I felt maybe I'll have better luck with some pseudo-coding.

    Basically this is how I'd like it to run:

    Any cells in B3:B26 that = "1G", then copy that entire row (which goes A:Q), and paste it into the A2 of a different worksheet called "ToPrint".

    Then, any cells in B3:26 that = "2T", then copy that entire row, into the same ToPrint worksheet, 3 cells down from the last row from the previous condition (i.e. "1G"). For example, if previously, the "1G" condition came up with 9 results, taking up A2:Q10 in "ToPrint", I want the "2T" condition to paste into "ToPrint" worksheet as well, and to paste it starting from A13 (leaving a 2 blank-cell gap between the 1Gs and 2Ts).

    Then the exact same thing for 2 more conditions, "3D" and "4W" also having a 2 cell gap between the pasted results.

    These 4 conditions results would replace whatever was in the ToPrint worksheet before as I'm going to be running this macro from 8 different sheets.

    Thank you so much for any and all help I receive. If you have any questions please feel free to ask.

    - Pat

    If you can't get the attachment, here it is on google docs. I've added what I'd like the ToPrint to look like (last sheet).

    PS: as an absolute bonus (not make or break), I'd like the the text that is in cell A1 of the sheet I run the macro off, to also be copied to the A1 of the "ToPrint" worksheet.
    Attached Files Attached Files
    Last edited by pato88; 05-18-2013 at 03:16 AM. Reason: Changed everything to be clearer and more helpful

  2. #2
    Registered User
    Join Date
    05-16-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

    Anyone? This is for a summer camp swimming class I'm running soon (in the U.S.) and this function alone would make my life so much easier as it's something I have to frequently do.
    Last edited by pato88; 05-18-2013 at 03:11 AM.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

    Not the nicest code but it might get you started
    Try it on a copy of your workbook

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-16-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

    Quote Originally Posted by jolivanes View Post
    Not the nicest code but it might get you started
    Try it on a copy of your workbook

    Please Login or Register  to view this content.
    Hey man thanks so much in the interest you've put in and the time it took you to make the code.

    Unfortunately it doesn't work, it says "Run-time error '1004': Method 'AutoFilter' of object 'Range' failed" on line 9. I don't know enough to be able to fix/get around that.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

    Try the attached.

    BTW, don't quote unless it is really required.
    Attached Files Attached Files
    Last edited by jolivanes; 05-19-2013 at 12:33 PM.

  6. #6
    Registered User
    Join Date
    05-16-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Macro to use multiple IF statements to copy and paste to dif places of a dif worksheet

    Thanks again for your help.

    I encountered the same problem on the same line with your version.

+ 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