+ Reply to Thread
Results 1 to 10 of 10

Autofilter, copy, paste to new file

  1. #1
    Registered User
    Join Date
    03-28-2018
    Location
    ISRAEL
    MS-Off Ver
    2010
    Posts
    15

    Autofilter, copy, paste to new file

    Hello,

    Can anyone help me with some code that can autofilter, copy, and paste to a new sheet that is named after the filtered field?

    Row 1 has column headers and column A contains the unique values (Names) that I want to filter by. There will be multiple rows containing each names. last column for this table is O.

    I don't know all of the unique values that could be in column A. Is there a way to write the code to make the macro filter each unique value without knowing what those values are?

    I also need it to create a new file and name the file after the unique value (name) from column A.

    Next, it would need to copy the filtered data and paste it to the newly created file.

    It would need to repeat this process until each unique data set has been copied to its own file.

    Thanks for any help.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Autofilter, copy, paste to new file

    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    03-28-2018
    Location
    ISRAEL
    MS-Off Ver
    2010
    Posts
    15

    Re: Autofilter, copy, paste to new file

    It works! thanks!

    2 more questions-
    1.How do I change the location of the new save files ?
    2. How do I add a LOOP to make the same procedure in the other 2 sheets of the original file?

    Thanks,
    Limor
    Last edited by Limor; 03-28-2018 at 09:17 AM.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Autofilter, copy, paste to new file

    For all sheets in workbook

    Please Login or Register  to view this content.
    to change the location, change the red part.

    Kind regards
    Leo

  5. #5
    Registered User
    Join Date
    03-28-2018
    Location
    ISRAEL
    MS-Off Ver
    2010
    Posts
    15

    Re: Autofilter, copy, paste to new file

    Hey,
    I'm afraid it's not working well.
    I have 2 sheets, in each sheet I want to do the same thing (as mention before) and filter by the same name in both sheets, than move those 2 sheets to another workbook and save it in that name. and than loop for all.

    I tried to wright something but it's not working since i'm a junior in VBA :/

    Can you please have a look or propose something else?

    appricate it a lot !

    Please Login or Register  to view this content.
    Last edited by AliGW; 04-01-2018 at 03:27 AM. Reason: Code sample reinstated - please do NOT post-edit your posts!!!

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Autofilter, copy, paste to new file

    you did not use the code provided in # 4

    only thing to do there is change thisworkbook.path & "\" to "C:\Users\limor.tzach\Google Drive\Commission\2018\Monthly VBA\Statement" & "\"

    Cheers
    Leo

  7. #7
    Registered User
    Join Date
    03-28-2018
    Location
    ISRAEL
    MS-Off Ver
    2010
    Posts
    15

    Re: Autofilter, copy, paste to new file

    The address issue did work well but not the LOOP.

    The code in # 4 split each of the filtered sheets to different files (instead of having 1 file with 2 sheets of the same criteria in the filter.)

    Any suggestions?

  8. #8
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Autofilter, copy, paste to new file

    can you provide exemple with original data and extra sheets with desired result ?

    Kind regads
    Leo

  9. #9
    Registered User
    Join Date
    03-28-2018
    Location
    ISRAEL
    MS-Off Ver
    2010
    Posts
    15

    Re: Autofilter, copy, paste to new file

    Yes,
    The Test1 file is the original file and the other file is the desired outcome.

    thanks!
    [attach]
    Attached Files Attached Files
    Last edited by Limor; 03-29-2018 at 11:06 AM.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Autofilter, copy, paste to new file

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    No further help to be offered, please, until the OP has complied with this request.


    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. [SOLVED] Need Macro to autofilter and copy data and paste in new file
    By suyogpatil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-31-2015, 02:37 AM
  2. [SOLVED] Copy & Paste Using Autofilter
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2013, 08:45 AM
  3. [SOLVED] Copy & Paste with Autofilter on
    By NeedForExcel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-27-2013, 07:18 AM
  4. [SOLVED] Autofilter - copy & paste
    By Dorothy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-29-2006, 06:00 PM
  5. Copy/Paste in Autofilter
    By honyacker in forum Excel General
    Replies: 2
    Last Post: 01-12-2006, 10:45 AM
  6. Replies: 1
    Last Post: 10-17-2005, 04:05 AM
  7. [SOLVED] Autofilter and Copy and Paste
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2005, 02:06 PM

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