Create & Save filtered list into new workbook

  • Hello,


    I have a workbook that has 9 tabs. I would like to have a VBA that automatically filters tab 2, for each of the names in column B. Then, it would save all the tabs in the workbook with the name that the list is filtered for on tab 2. All the workbooks would contain the same data, the the difference between each workbook would be the filtered list on tab 2.

  • Re: Create & Save filtered list into new workbook


    Can't quite follow - it sounds like you want to save a copy of the workbook for each unique name in Sheet2/Col B but the only information in Sheet 2 is the name used for that workbook?
    Upload a sample - it may help to see your data.


    [sw]*[/sw]

  • Re: Create & Save filtered list into new workbook


    Thank you for your reply. The idea is to filter column B by each value listed (total of 33 unique names) and saving the workbook as "Name M1", "Name M2", Etc. The new workbook would contain all the tabs as the original workbook but the list on tab 2 would be filtered.


    Please let me know if this makes sense,


    Thank you in advance.[ATTACH=CONFIG]70170[/ATTACH]

  • Re: Create & Save filtered list into new workbook


    Quick and dirty...


    All the code goes in a module in the workbook to be copied. It could be speeded up a bit as it is mostly linear code without much optimisation but it seems to work.


    Assumptions have been made - the workbooks will be saved in the same directory as the 'parent' workbook; you will get prompted if a file already exists when saving, it will not overwrite.


    (The code formatting seems to have an error - that red line compiles OK in Excel)

  • Re: Create & Save filtered list into new workbook


    cytop,


    Thank you very much for the code and your time. I have a quick question about the new workbook that is saved. Is it possible to omit the step where the hidden rows on the new workbook are deleted? I would like to save the filtered list as is, instead of only moving the visible cells to a new workbook.

  • Re: Create & Save filtered list into new workbook


    Misunderstood what you wanted to do with the hidden rows.


    Simply comment out/delete the line calling the procedure RemoveHiddenRows. The procedure itself can also be removed

  • Re: Create & Save filtered list into new workbook


    Cytop,


    Removing the hidden rows procedures saves only saves a new workbook but the list is not filtered in this new workbook.
    'RemoveHiddenRows ActiveWorkbook.Sheets("2."), colNames(lngItem)


    do I need to rearrage the procedures?

  • Re: Create & Save filtered list into new workbook


    My apologies - I changed the structure of the code and forgot.


    Instead of commenting out the call to the procedure, just comment these lines (in RemoveHiddenRows):



    although it should have been easy enough to follow as comments were included with each block of code that actually did sometihng.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!