VBA filter column macro helps filter the data in a specific Column. Let us see different example macros to filter the records or rows based on items in one column. Example Data to Explain the VBA Filter:
VBA Filter Column

Here is the Example data to illustrate the macro on VBA Filter Column. This Example Data sheet contains 100 records with sample data items. We have created employee records with columns: Serial Number, Name, Country, Department, DOJ and Salary to explain this topic.

VBA Filter Column – Excel Data

VBA to Filter data in a specific Column:

Let us see an Example VBA macro to filter the records in a worksheet. This Example shows how to filter Data based on an item in Column C using Excel VBA.

We have 100 rows in the data sheet and Country details in Column C. Let us filter the data to show only records from county US. i.e; We need to apply the filter on Column C and set the criteria as US.

Here is the VBA Code created with Macro Recorder:

Sub Macro1()

' Macro1 Macro 

Columns("A:F").Select

Selection.AutoFilter

ActiveSheet.Range("$A$1:$F$101").AutoFilter Field:=3, Criteria1:="US"

End Sub

Let us Clean the code to have the final VBA code to filter the data in Column.

Sub sbAT_VBAMacroToFilterColumn()

' VBA Code to filter records of Columns A to F based on the data item in Column C

ActiveSheet.Range("$A$1:$F$101").AutoFilter Field:=3, Criteria1:="US"

End Sub

 

We have removed all unnecessary code and left with the required code for filtering the data.
Let us see the code in-depth:

We are using the AutoFilter method of the range. In the above code, we have created a macro to apply the filter on Range A1:F101 of the active worksheet. And applied the filter on Column 3 and set the criteria as US.

This Example macro will filter the records in Range A1:F101 and show all records with US in Column 3 , i.e; in Column C. Here is the final out put of the VBA Filter Column Macro:

VBA Filter Column – Filtered Data

VBA Filter Column – Download the Example File

Here is the Example file with sample data. You can download the Excel VBA Macro file and Explore to see the VBA code to filter column data.

VBA Filter Column – Example Macro File

 

Executing the Macro: VBA Filter Column:

  • Open the Example File
  • Go to Data sheet
  • Open VBA Editor (Press Alt+F11 to open it)
  • And Run the Macro by pressing F5 Key.

Now you can see the filtered records in Active sheet.

 

Premium Project Management Templates

120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

PREMIUM TEMPLATES
LIMITED TIME OFFER
ON SALE80% OFF
BROWSE ALL TEMPLATES

Advanced Project Planning Templates

Excel Templates

VIEW DETAILS

120+ Project Management Templates Pack

Excel | PowerPoint | Word

VIEW DETAILS

ULTIMATE RESOURCE MANAGEMENT TEMPLATE

Excel Template

VIEW DETAILS

50+ Essential Project Management Templates

Excel | PowerPoint | Word

VIEW DETAILS

Project Portfolio Management Templates

Excel | PowerPoint Templates

VIEW DETAILS

50+ Excel Project Management Templates

Excel Templates

VIEW DETAILS

By Published On: June 27th, 2018Categories: VBA Filter

Share This Story, Choose Your Platform!

About the Author: PNRao

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).