+ Reply to Thread
Results 1 to 8 of 8

filter table and copy unique value to mulitple sheets

  1. #1
    Registered User
    Join Date
    03-18-2012
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    42

    filter table and copy unique value to mulitple sheets

    hi everyone,

    I am trying to build a macro that will loop through filters and copy the unique values to sheets based on the filters. I've seen a few codes based on unique values and copy but can't seem to find one matches my needs.

    example:

    sheet 1 - in cell A1 I have a list of countries.
    A1 - Canada
    A2 - USA
    A3 - Asia
    A4 - Europe

    Sheet 2 - this is my data tab with a table. my Table range is from D5:O5. column J is countries

    Sheet 3 - Canada
    Sheet 4 - USA
    Sheet 5 - Asia
    Sheet 6 - Europe

    What I'm trying to do is on sheet 2 filter column J from Sheet 1 and then copy the unique values of column E and paste it in A1 of the corresponding sheet.

    ideally a for loop that will check how many countries and then filter each one in sheet 2 and copy the results to the correct sheet.



    any help would be appreciated.
    Attached Files Attached Files
    Last edited by matrix_xrs; 08-03-2016 at 11:08 AM.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: filter table and copy unique value to mulitple sheets

    can you post an example sheet to work with?
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    03-18-2012
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: filter table and copy unique value to mulitple sheets

    attached to original post.

    my example includes the results I like for each country tab.


    thanks

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: filter table and copy unique value to mulitple sheets

    You don't need, nor would it be better, to use VBA for this. Your country sheets (like Canada) can be produced with Pivot Tables.

    You could change the Filter value to see other countries, don't really need to make a sheet for each possible country (but you can if you like).
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-18-2012
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: filter table and copy unique value to mulitple sheets

    I would prefer to do it through vba as I'm doing more things with the data afterwards. I have sumif and sumproduct formulas. using a pivot limits me on what formula I can use.

    any way this can be VBA?

  6. #6
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: filter table and copy unique value to mulitple sheets

    Quote Originally Posted by matrix_xrs View Post
    I would prefer to do it through vba as I'm doing more things with the data afterwards. I have sumif and sumproduct formulas. using a pivot limits me on what formula I can use.
    Well, you just have to direct your formulas back to the original data set. Would be easier to show this with an example than to try and convince you in a message.

    But ... yes, you can do what you are wanting in VBA. See attached.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-18-2012
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: filter table and copy unique value to mulitple sheets

    hi, this is great.

    is there a way to use the advance filter and copy only the unique values of column E?

    right now it applies the country filter and copies the data but i would like to apply the country filter and then copy only the unique value of column E.

  8. #8
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: filter table and copy unique value to mulitple sheets

    I didn't use the Country filter, I used the list of Countries on the 'Country' sheet. To do what you ask is possible... but: what you want is EXACTLY what a pivot table does.


    Here is my advice: You should change what you are doing to work with the native features of Excel. Instead of working Excel around your personal style.There is no reason that the 'other calculations' you mention have to interact with the pivot tables. It is possible just refer to the underlying data set.

    If that is no good, I suggest you start googling how to adapt my code to do whatever you need :D

    At some point you just have to stop helping someone trying to reinvent the wheel.

+ 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. Filter unique and copy macro
    By Milo0309 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2015, 06:02 PM
  2. Filter and copy/overwrite to a new workbook and rename to unique filter value
    By gssc141 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2015, 10:28 AM
  3. Mulitple Pivot Table Filter updates...Excell 2007 question.
    By kriordan13 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 04-09-2014, 01:12 PM
  4. Apply Mulitple Filters and Copy Data into New Sheets
    By ashishmac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2013, 06:07 AM
  5. [SOLVED] VBA to only copy unique records from a filter
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2012, 10:13 AM
  6. Pivot Table with Mulitple Sheets
    By Jerry.Peoples in forum Excel General
    Replies: 0
    Last Post: 04-20-2010, 10:26 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