Filtering Columns (without using the filter function!)

ellison

Active Member
Joined
Aug 1, 2012
Messages
343
Office Version
  1. 365
Platform
  1. Windows
Hi, the code below (that Peter posted) so that we can use a "multi-filter" on our spreadsheets has been BRILLIANTLY helpful.

In short, it filters all of the data on a given spreadsheet for whatever search strings are placed in Row 1.
So at the moment we could filter Column A for "red", Column B for "plastic" and Column C for "rounded".

But what we would like to do is add in multiple options on our filters... like an "OR" option
i.e. search Column A for "red" OR "yellow" or "blue" and then Column b for "plastic" and Column C for "rounded"

(We are on a mission to clean up our data and collating all the different reports was like pulling teeth. Using Peter's code has been superb and tweaking it to include this feature would be the cherry on the cake!)

Best

Neil



Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range, c As Range
Dim FilterRangeFirstCol As Long, FieldCol As Long
Dim sCrit As Variant

If ActiveSheet.AutoFilterMode Then
With ActiveSheet.AutoFilter.Range
Set Changed = Intersect(Target, .EntireColumn, Rows(1))
If Not Changed Is Nothing Then
FilterRangeFirstCol = .Column
For Each c In Changed
FieldCol = c.Column - FilterRangeFirstCol + 1
If IsEmpty(c.Value) Then
.AutoFilter Field:=FieldCol
Else
If IsNumeric(c.Value) Then
sCrit = c.Value
Else
sCrit = "*" & c.Value & "*"
End If
.AutoFilter Field:=FieldCol, Criteria1:=sCrit
End If
Next c
End If
End With
End If
End Sub



 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,338
Messages
6,124,349
Members
449,155
Latest member
ravioli44

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