0

In my job, every day I receive excel file with 2 columns (A1, B2) of unsorted data. For example:

A1 B2
DD E
AA Y
CC C
AA W
CC B
CE I
AA P
CE C
DD Y

What I wanted to do is to sort it first by 2 letters of cell in first column and then by text in second column. Like this:

A1 B2
AA P
AA W
AA Y
CC B
CC C
CE C
CE I
DD E
DD Y

As you can see, text in B2 is sorted from A to Z, but within groups from A1 (AA, CC, CE, DD)

To be honest, I'm not very familiar with Excel. This kind of multiconditional sorting I need to create in some macro, vba?

I tried to use multisort option (sort by Column A, Sort on Values, order A to Z, then sort by Column B, Sort on Values, order A to Z) but it's not working how I wanted. Can somebody help me with this problem?

New contributor
Takaim Lys is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    Add a level to your sort (top left button in the sort window) – cybernetic.nomad Feb 14 at 19:40
  • 1
    "I tried to use multisort option (sort by Column A, Sort on Values, order A to Z, then sort by Column B, Sort on Values, order A to Z) but it's not working how I wanted." How is it working? This will do what you are asking to do. – Alex M Feb 14 at 19:59
  • Sorry, but after using that, it just sort all cells in B2, but destroy sorting in A1. Maybe I'm doing something wrong here? – Takaim Lys Feb 14 at 20:05
  • 1
    You clearly are doing two sorts instead of adding a level to a single sort – cybernetic.nomad Feb 14 at 20:45
  • 1
    If you want a sort to only take the first two characters in some cells into account, the easiest thing may be to have a helper column with said two letters – cybernetic.nomad Feb 14 at 21:12
0

in column C use the following formula =left(A1,2)&B1 or whatever appropriate cell reference, then sort only by column C

Your Answer

Takaim Lys is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.