VBA – Filters and Reporting

VBA – Filters and Reporting

AutoFilter is applicable to a column or a set of columns. It filters data depending on the given criteria. The filter displays a certain number of lines based on defined criteria.
training for excel basic and advanced free

Syntax:

expression .AutoFilter(Field, Criteria1, Operator, Criteria2, VisibleDropDown)

Where

Field– It is an integer offset of the field which contains the Filter. The data type is variant, which means it can hold any Data types – integers, strings, date and so on.

Criteria1– It’s a condition based on which columns are selected.

Operator– It specifies the type of filter.
excel corporate training solutions
 

 

Example 1: To Close All Existing AutoFilters and Create New AutoFilters
corporate training excel

Sub AutoFilter1()

With ActiveSheet

‘Turns off any existing AutoFilters if any..

.AutoFilterMode = False

‘ Now apply AutoFilter to a Range

.Range(“A1:C1”).AutoFilter

End With

End Sub
corporate training in excel
Example 2: Using AutoFilter to match single criteria

Sub FilterTo1Criteria()

With Sheet1

.AutoFilterMode = False

.Range(“A1:C1”).AutoFilter

.Range(“A1:C1″).AutoFilter Field:=2, Criteria1:=”North”

End With
training for excel macros
End Sub

Enjoy the tutorial? Please spread the word :)

Follow by Email
Facebook
Facebook
Google+2k
Google+
http://hirdeshbhardwaj.com/2017/10/23/corporate-training-in-delhi-ncr
YouTube44
YouTube