SORT/FILTER formula

uk747

Well-known Member
Joined
Jul 20, 2011
Messages
843
Office Version
  1. 365
Platform
  1. Windows
CatRed
8​
DogBlue
7​
PigRed
6​
ElephantGreen
5​
BearYellow
2​

Hi
Trying to Filter A2:C100 Where Column B = "Red" and SORT 3rd Column Ascending. If Red Doesn't appear I want to use the IfEmpty Argument

I've used =SORT(FILTER($A$2:$C$100,($B$2:$B$100 = "Red")),3,1) which works, however I need to edit in case there aren't any results
i.e. =SORT(FILTER($A$2:$C$100,($B$2:$B$100="Red"),"Nothing to See HERE!"))
But when I add the Sort part to this I get a #Value! Error if Red doesn't appear in Column B =SORT(FILTER($A$2:$C$100,($B$2:$B$100="Red"),"Nothing to See HERE!"),2,1)

Result should be

PigRed
6​
CatRed
8​
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You could try:
Excel Formula:
=IFERROR(SORT(FILTER($A$2:$C$100,($B$2:$B$100="Red")),2,1),"Nothing to See HERE!")
 
Upvote 0
Thanks but trying to avoid IFERROR argument
 
Upvote 0
I could only get it to work by sorting both ranges:
Excel Formula:
=FILTER(SORT($A$2:$C$100,3,1),SORT($B$2:$B$100,1,1)="Red","Nothing to See HERE!")
 
Upvote 0
You could also do it like
Excel Formula:
=SORT(FILTER($A$2:$C$100,($B$2:$B$100 = "Red"),{"No data","",""}),3,1)
 
Upvote 0
Solution
@Fluff Is: {"No data","",""} one part for each column of the array?

I am still learning advanced formula, I mainly use VBA.
 
Upvote 0
That's right, so for 3 columns it's ok, but it would need a different approach if there were a lot of columns.
 
Upvote 0
I could only get it to work by sorting both ranges:
Excel Formula:
=FILTER(SORT($A$2:$C$100,3,1),SORT($B$2:$B$100,1,1)="Red","Nothing to See HERE!")
That workded for no results but didnt get both red values


pigred
6​
DogBlue
7​
 
Upvote 0
You could also do it like
Excel Formula:
=SORT(FILTER($A$2:$C$100,($B$2:$B$100 = "Red"),{"No data","",""}),3,1)

Thanks that seemed to work:)
Is it possible to edit for partial search i.e. red if it was cred tred etc
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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