Approach to sorting and index/match

RonOliver

Board Regular
Joined
Aug 30, 2022
Messages
99
Office Version
  1. 365
Platform
  1. Windows
Hi.
Let me paste these two sheets:

Sheet1...
Book1
ABCD
1FIRST NAMELAST NAMEID NUMBERE-MAIL
2MichaelWalker123456789mike@gmail.com
3SarahWalker234567891walker.sarah@gmail.com
4JohnTimmons345678912john@gmail.com
5AshleyBjornsdottir456789123bjorn@gmail.com
6AndrewWest567891234west@hotmail.com
7LesJohnson678912345johnson@hotmail.com
Sheet1


and Sheet2...

Cell Formulas
RangeFormula
A2:A7A2=IF(AND(ISBLANK(Sheet1!A2:A7)),"",PROPER(SORT(FILTER(Sheet1!B2:B7,Sheet1!B2:B7<>""))))
B2:B7B2=IFERROR(PROPER(INDEX(Sheet1!$A$2:$A$7,MATCH(A2,Sheet1!$B$2:$B$7,0))),"")
C2:C7C2=IFERROR(PROPER(INDEX(Sheet1!$C$2:$C$7,MATCH(A2,Sheet1!$B$2:$B$7,0))),"")
D2:D7D2=IFERROR(PROPER(INDEX(Sheet1!$D$2:$D$7,MATCH(A2,Sheet1!$B$2:$B$7,0))),"")
Dynamic array formulas.


The second swaps first and last name and sorts everything by last name. However, by using index/match, if two people have the same last name, I'm only getting the first instance where it matches. Can you please let me know if you would try a different approach? This is a reduced version of my sheet, which has a lot more columns, so not all approaches will work. I'm just asking if there's something I'm doing fundamentally wrong.

Thanks everyone!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Oh, nevermind. I had miscalculated the range. It works now. Sorry for the hassle.

Thanks so much! I love the formula, but now I don't know how to use UPPER(), LOWER(), etc. in different columns. There's also a column that should display a date of birth, but it displays it as a five digit number. Tried changing the cell format, but I can't get it to work. I might need helper columns, but that's gonna require a complete overhaul.
 
Upvote 0
If you don't want to go the Power Query route, which is something that would be well worth your time to learn, then something like this might work for you.

Excel Formula:
=LET(fltr,FILTER(SORTBY(Sheet1!A2:D7,Sheet1!B2:B7,1,Sheet1!A2:A7,1),Sheet1!B2:B7<>""),
     fName,PROPER(CHOOSECOLS(fltr,1)),
     lName,PROPER(CHOOSECOLS(fltr,2)),
     ID,UPPER(CHOOSECOLS(fltr,3)),
     eMail,LOWER(CHOOSECOLS(fltr,4)),
     HSTACK(lName, fName, ID, eMail))
 
Upvote 1
Solution
If you don't want to go the Power Query route, which is something that would be well worth your time to learn, then something like this might work for you.

Excel Formula:
=LET(fltr,FILTER(SORTBY(Sheet1!A2:D7,Sheet1!B2:B7,1,Sheet1!A2:A7,1),Sheet1!B2:B7<>""),
     fName,PROPER(CHOOSECOLS(fltr,1)),
     lName,PROPER(CHOOSECOLS(fltr,2)),
     ID,UPPER(CHOOSECOLS(fltr,3)),
     eMail,LOWER(CHOOSECOLS(fltr,4)),
     HSTACK(lName, fName, ID, eMail))
Thank you from the bottom of my heart. This is exactly the solution I was looking for.

I guess I have no other choice but to learn Power Query next time. :)
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,048
Members
453,014
Latest member
Chris258

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