Filter across multiple columns, but without using helper column

ellison

Active Member
Joined
Aug 1, 2012
Messages
343
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm trying to filter for a single criteria across multiple columns.

- I'd normally use a helper column to concatenate the relevant fields together.
- Then copy / paste special / paste the "values" into the same helper column in order that they can be filtered.
- For example

RowModelMaterialColourHelper
2XYZ789WoodSilverXYZ789;Wood;Silver
3ABC123-4PlasticBlackABC123-4;Plastic;Black
414CV56576Wood14CV56576;Wood

EG If we wanted to view any row of info which contained "Wood", then the filter would show Rows 2 and 4.

Is there a way of doing this where I can make this work without having to copy / paste special / paste "values in the helper column? (otherwise my fat fingers seem to be causing all sorts of errors!).

Huge thanks
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Why not simply fix the data set so that the items are in the correct columns.....unles of course, wood IS a colour
 
Upvote 0
I also see your using 365, which contains a new function called =FILTER
Have a look here for examples, especially about halfway down where it says "more Than one Criteria"
 
Upvote 0
Why not simply fix the data set so that the items are in the correct columns.....unles of course, wood IS a colour
Would love to, but these are external reports that we have to tidy up. Every month. Joy!
 
Upvote 0
I also see your using 365, which contains a new function called =FILTER
Have a look here for examples, especially about halfway down where it says "more Than one Criteria"
a-ha, I'd been looking at that one...

The new FILTER option seems to copy the filtered data into a different location.

Whereas I need to be editing the data in its original location. (And some rows of data need multiple corrections).

Hope this helps
 
Upvote 0
This assumes that the data is in columns A-D.
VBA Code:
Sub MM1()
Dim r As Long
For r = 4 To 2 Step -1
    If Cells(r, 2).Value = "Wood" Or Cells(r, 3) = "Wood" Then
        Rows(r).EntireRow.Hidden = False
        Else
        Rows(r).EntireRow.Hidden = True
    End If
Next r
End Sub
 
Upvote 0
Hi Michael, huge thanks for the code!
I seem to be having a couple of gremlins, sorry.
I've entered this as a UDF.
Then when I ran it, Excel jumped to cell MM1 (as opposed to running the macro)

I hit Alt + F8 a second time and the data filtered (but missed out a row that would include "wood").

Which would leave my other gremlin: I couldn't see how to remove the filter to get back to the raw data?

(And last, could the code run the filter from the contents of a cell address eg "H1"? That way I could change the contents of cell H1 to "wood" or "plastic" etc without having to change the actual code)

Many thanks for your help Michael


When I run the mac
 
Upvote 0
You would have to rename it if you used it as a function, but you could simply run it usinf F8 and selecting the macro MM1
To get back to raw data simply click in the Intersect of rows and columns )just above row 1 and then right click and select "Unhide"
To use "H1" try...
VBA Code:
Sub MM1()
Dim r As Long, rng as range
set rng = cells(1,8)
For r = 4 To 2 Step -1
    If Cells(r, 2).Value = rng Or Cells(r, 3) = rng Then
        Rows(r).EntireRow.Hidden = False
        Else
        Rows(r).EntireRow.Hidden = True
    End If
Next r
End Sub
 
Upvote 0
Thanks Michael...
On the plus side, I renamed the UDF to Dynamic Test (rather than MM) and it worked with cell input "H1"- although still some gremlins.

- On the down side, it seems to be case dependent? (could this be avoided?)
- And sorry to say that it didn't pick up the second row of info (although it did pick up the first!)
- Also, I'm going to have to be toggling the filter on and off (a lot, deep joy !)....
- Is there a way of making that a little quicker / easier rather than clicking on the intersect?

Thanks again
 
Upvote 0
Hi,

I tried going back to seeing if using functions in a helper column would work.
But tried different methods of joining them together .... No luck I'm afraid

dynamic-test.xlsx
ABCDEF
1RowMakeModelColourHelperHelper-to-view-function
22onetwothree2onetwothree#=B2&C2&D2&E2
33onetwoBlack3onetwoBlack#=B3&C3&D3&E3
4414CV56576Wood414CV56576Wood#=B4&C4&D4&E4
55onetwothree5onetwothree#=CONCATENATE(B5,C5,D5,E5)
66onetwoBlack6onetwoBlack#=CONCATENATE(B6,C6,D6,E6)
7714CV56576Wood714CV56576Wood#=CONCATENATE(B7,C7,D7,E7)
88onetwothreeone;two;three#=TEXTJOIN(";",TRUE,C8:E8)
99onetwoBlackone;two;Black#=TEXTJOIN(";",TRUE,C9:E9)
101014CV56576Wood14CV56576;Wood#=TEXTJOIN(";",TRUE,C10:E10)
Sheet3
Cell Formulas
RangeFormula
E2:E4E2=A2&B2&C2&D2
E5:E7E5=CONCATENATE(A5,B5,C5,D5)
E8:E10E8=TEXTJOIN(";",TRUE,B8:D8)


If anybody has any suggestions, I'm all ears!

PS the sheet had a filter set on it
 
Upvote 0

Forum statistics

Threads
1,215,466
Messages
6,124,983
Members
449,201
Latest member
Lunzwe73

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