Getting '#Value!' With Combination of SORT, FILTER Formula

Arfur1963

New Member
Joined
Nov 9, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
Hi everyone,

I’m having trouble with an Excel formula and could use some help. Here’s what I’m trying to achieve:
  1. Filter data from a table named tblStudents using headers specified in the range C4:G4.
  2. Sort the filtered data based on a column named ‘New Class’.
Here’s the formula I’m currently using:

=SORT(FILTER(INDEX(tblStudents,SEQUENCE(ROWS(tblStudents)),XMATCH(B4:N4,tblStudents[#Headers])),tblStudents[No.]<>""),XMATCH("New Class",tblStudents[#Headers]),-1)
This formula works when I use the range B4:N4, but it gives a #VALUE! error when I change the range to B4:M4.

Questions:
  • Why does changing the range from B4:N4 to B4:M4 cause a #VALUE! error?
  • How can I modify the formula to work correctly with the B4:M4 range?
Any insights or suggestions would be greatly appreciated!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi & welcome to MrExcel.
If the New Class column is the 13th column of the table, that would explain why.
Also there is a very good chance you will not be sorting the data on the correct column.
 
Upvote 0

Forum statistics

Threads
1,223,374
Messages
6,171,713
Members
452,418
Latest member
kennettz

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