Excel Create Worksheet per Filter Value | VBA Macro #16

Macro Intro

This is an Excel macro that will filter a column and create a new worksheet for each unique value found. By default, the active column selected will be filtered. If the active column selected is blank an InputBox will ask for the column number to filter. (Example: A=1, B=2, C=3, etc.) Once a column has been identified the duplicate values will be removed and what remains will be used to determine how many worksheets to create. The Excel Create Worksheet per Filter Value macro will then pull in the relevant information into each worksheet. This macro is an efficient way to view your data in separate worksheets. You could filter and checkmark one option at a time but this is labor some, especially if you want to analyze each value independently. It takes even more time to copy and paste information into its own worksheet. Using VBA, you can eliminate the manual work and complete all these actions at once!

See it in Action

Watch this video to see this macro in action.

Code

Here is the code for this macro. Make sure the following References are setup before running it: Visual Basic For Applications, Microsoft Excel 16.0 Object Library, OLE Automation, Microsoft Office 16.0 Object Library

Customization

These segments of code can be customized to personalize this macro.
If the filtered column returns more than 50 values the macro will exit to ensure the Excel can handle the request. Update this number to reflect how you want this to behave.
If you are not working with a header row then you should change Counter = 1
If you don’t want the filter to be removed from the first spreadsheet make this line a comment with ‘
If you don’t want the duplicates column to be deleted from the first spreadsheet make this line a comment with ‘
If you don’t want this macro to finish with a MsgBox then make this line a comment with ‘
Search

First time using VBA?

The Developer Tab is an additional section of the ribbon when activated allows you access to Visual Basic in Applications like Access, Excel, Outlook, PowerPoint, Word.
Setup Now
Once the Developer Tab is available you will have the capability to update your security to allow Macros to run in the current application.
Setup Now
A sub of code is a collection of objects and variables. For the code to successfully run a library of references needs to be set.
Setup Now
Subscribe as an Insider to receive additional rights.
If you like our content and want to show your support tip us here!

Contact Us

Looking to improve your computer processes?
Leverage & Lean is here to help!

Powered By MemberPress WooCommerce Plus Integration

Free Macro

Start creating Less Clicks, More Results today!