+ Reply to Thread
Results 1 to 6 of 6

Copy Paste Macro Based on Criteria

  1. #1
    Registered User
    Join Date
    01-13-2010
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    57

    Copy Paste Macro Based on Criteria

    Hi All

    I'm sure this one has popped up many times but I can't find one to suit what I am trying to achieve

    I want to create a macro that will copy and paste selected rows based on the value in column A

    For example

    In Column A I will have all my continent names (Europe, Asia, North America etc) and each 1 has 5 rows of information for each continent next to it in Column B

    A B

    1 EUROPE England
    2 France
    3 Germany
    4 Spain
    5 Portugal

    So when the macro searches Column A and finds the continent it will copy the data for the whole rows from B1:B5 and paste it into a tab with the same name into the same row numbers (in this example it would copy and paste to a tab called EUROPE into rows B1:B5)

    Trying to automate this as I need to do it for every continent and group the countries manually at the minute

    Thanks in advance

    Dan_B

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Copy Paste Macro Based on Criteria

    Hi Dan, I suggest a sample workbook so hat we know what the layout is.
    Make sure it doesn't contain private or sensitive data.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    01-13-2010
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Copy Paste Macro Based on Criteria

    Thanks Keebellah - I've attached the file to this response thread

    Hopefully this makes it a bit clearer
    Attached Files Attached Files

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Copy Paste Macro Based on Criteria

    Okay, makes sense.
    The continent only appears once and until the next one appears the data of those rows goes to a new sheet with the name of the continent.
    Correct.
    What to do with the copied original. clear the contents?

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Copy Paste Macro Based on Criteria

    see if the attached helps you

    ctrl + t will fire the macro
    Attached Files Attached Files
    Teach me Excel VBA

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Copy Paste Macro Based on Criteria

    I assumed that the user dit not want an input box.
    This one takes care of it and if there are more countries, the code works.
    As long as you just fill in one continent and the the countries it works, so it's 'dynamic'
    BTW the macro's name is MakeSheets (no shortcut key)
    Attached Files Attached Files
    Last edited by Keebellah; 02-08-2017 at 03:33 AM. Reason: forgot the attachment

+ 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. Macro to copy and paste based on multiple criteria
    By jmack36 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2016, 09:49 AM
  2. Replies: 3
    Last Post: 09-27-2013, 04:33 PM
  3. [SOLVED] Macro to copy and paste based on criteria to 11 separate sheets
    By msmith7113 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2013, 02:30 AM
  4. [SOLVED] macro to copy/paste based on a criteria
    By winger in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-27-2012, 09:55 AM
  5. Copy Paste cells into a new sheet based on criteria macro
    By Clessie1919 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-19-2012, 02:43 AM
  6. [SOLVED] Macro to copy and paste rows to a new sheet based on criteria
    By Belo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-31-2010, 02:25 AM
  7. Excel Copy and Paste Macro based on criteria
    By RobbieBobbie23 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-16-2007, 11:38 AM

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