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.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 HIDE MENU RIBBON IN MS ACCESS In MS Access, there are multiple ways to protect your code or tool from un-authorized access and edits. Some developers prefers to hide MS Access ribbons…
File Manager tool is an Excel based tool which helps you to delete or move unwanted files from your system. It requires a source and destination folder (in case you want to move files). First it lists all the files available in the folder or sub-folders then you can select the action to be taken for each file such as Move or Delete. With a click of button, tool will take all necessary actions.
How to use VBA to open Workbook in Excel? There are few VBA codes which are commonly used by every developer. One of them is giving an option to user to browse a file. Below is a…
Did you come across any requirement where you want the user to interact with a sheet only through VBA Form? Here is a simple code which can help you here.
VBA Code to Sort Data HERE IS A ONE LINE CODE FOR DEVELOPER’S REFERENCE WHICH CAN BE USED TO SORT DATA ‘Sort data in ascending order on Column F (Created At) Sheet1.Range(“A1:G” & Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Row).Sort Key1:=Sheet1.Range(“F1”),…