VBA for Filtering 3 criterion

chiswickbridge

Board Regular
Joined
Feb 2, 2013
Messages
127
I have a database from A1:I1001, with Row 1 as the header.


Need a VBA to filter data using 3 criterion, in columns B, H and I based on the value input in cells M1, N1 and O1 respectively.


Easy so far... the catch is the following....


Column B has Long names....like.... Aditya Birla Sun Life Asset Allocation Fund - Conservative - Dividend Plan


Column H has Long names....like.... Raman Kumar Khosla.


Column I has Long names....like.... ICICI Pru Banking.




But, cells M1, N1 and O1 will have short names, 5 alphabets, like M1=Adity, N1=Raman and O1=ICICI....the filtering process must filter all names in Column B containing the word "Adity"...something like Criteria1:="=*Adity*", Criteria2:="=*Raman*", Criteria3:="=*ICICI*"


For the next operation, user will change the value in M1, N1 and O1,by a 5 digit text value




Hope I am clear... Thanks :)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If I understood you correctly this should do it

Code:
Sub FiltCrit()

    With ActiveSheet.Range("$A$1:$I$1001")
    .AutoFilter Field:=2, Criteria1:="=*" & Range("M1").Value & "*", Operator:=xlAnd
    .AutoFilter Field:=8, Criteria1:="=*" & Range("N1").Value & "*", Operator:=xlAnd
    .AutoFilter Field:=9, Criteria1:="=*" & Range("O1").Value & "*", Operator:=xlAnd
    End With
    End Sub

You can change the ActiveSheet to your actual sheet same for the range
 
Upvote 0

Forum statistics

Threads
1,216,067
Messages
6,128,590
Members
449,461
Latest member
jaxstraww1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top