Here is an easy reference code which filters data in the sheet. In the code, we have filtered the data in three steps.
Step 1: Remove existing filter from the sheet (if any). This code ensures if there is already a filter applied then the same is removed first
Step 2: Apply filter on 5th column (E) of the data where Country is Japan
Step 3: Apply filter on 4th column (D) of the data where Department ID is 711
'This function can be used to filter data
Public Sub FilterData()
'Reset/Remove filter from sheet
Sheet1.AutoFilterMode = False
'Apply first filter on 5th column (E) in the data where Country is Japan
Sheet1.Range("A1:G" & Sheet1.Range("A10000").End(xlUp).Row).AutoFilter 5, "Japan"
'Apply second filter on 4th column (D) in the data where Department ID is 711
Sheet1.Range("A1:G" & Sheet1.Range("A10000").End(xlUp).Row).AutoFilter 4, "711"
End Sub
'This function can be used to filter data
Public Sub FilterData()
'Reset/Remove filter from sheet
Sheet1.AutoFilterMode = False
'Apply first filter on 5th column (E) in the data where Country is Japan
Sheet1.Range("A1:G" & Sheet1.UsedRange.Row).AutoFilter 5, "Japan"
'Apply second filter on 4th column (D) in the data where Department ID is 711
Sheet1.Range("A1:G" & Sheet1.UsedRange.Row).AutoFilter 4, "711"
End Sub
Hope You like this article. Please share this with your friends and colleagues.
Happy Reading
In this article we are going to show you how you can delete file or files using a single line of VBA code. 1. Delete a specific file from the folder, 2. Delete specific type of files from the folder, 3. Delete all files from the folder
VBA Code to Convert MM.DD.YYYY To DD.MMM.YYYY in Excel In different parts of the world, there are different languages spoken and written. With this, a VBA programmer also faces language related issues while writing a…
To ensure that your VBA project works smoothly without any error, you need to put lot of error handlers and validations. Here is one of them, below code can be used to check if the given path is valid or not. You just need to provide the path of the file to the function and it will check if the file exist at the location. If it returns True that means the file is available at the path, if it returns False that means it is invalid path or the file does not exist at the location.
Free File Renamer Tool – Quickly Rename files batch using Excel VBA Here is another help code and tool for programmers to rename files. You can use this tool for renaming all files available in…
Random Rows Selector is an MS Excel based tool which can be used to pick random or stratified samples from a set of records available in the Excel. The tool is fully dynamic, it can support any data format in Excel.
VBA Code to list Files in Folder To work on multiple files through VBA programming, you need to have VBA code that can list files in a folder. In this article we will learn three…