Forum Discussion
Sort 2 columns into 1
Hey, I'm trying to port some of my google sheets into excel, and I'm finding that there are many simple things that are just not working
For example, I have two separate columns each filled with dates, and I need to sort them in a third column, here's what it looks like in google sheets., the code I'm using is =UNIQUE(SORT({B4:B;G4:G},1,TRUE))
I've been trolling every excel help site I can find, but nothing has worked. What got the closest was {=SORT(B4:B49*G4:G49)}, however the function didn't work with the curled brackets before the equal, as it was shown on the help site, and also didn't work when I reformatted it.
I feel like this should be simple?
4 Replies
- BudgotMakinTotsIron Contributor
Use the SORT function to merge two columns and sort them:
=SORT(CHOOSE({1,2}, A2:A100, B2:B100), 1, 1)
You can also copy the two columns to a new column → sort by the new column With VBA automation:
Range("C1:C200").Value = Application.Transpose(Array(Range("A1:A100"), Range("B1:B100"))) Range("C:C").Sort Key1:=Range("C1"), Order1:=xlAscending
- SnowMan55Bronze Contributor
For non-adjacent columns:
=SORT(UNIQUE(TOCOL(VSTACK(B4:B100, G4:G100), 1)))
- Patrick2788Silver Contributor
The easiest move is to convert the 2-column array into a single column, remove dupes, and sort.
This is the idea:
=SORT(UNIQUE(TOCOL(B2:C10)))