# Sorting with merged cells

#### levy77

##### Board Regular
Hi,

I'm trying to sort the below table on the 'OVERALL' values, the issue I'm having is that as 'OVERALL', 'M/F' ... etc are all merged. When the sort is run essentially candidate 1 with all their data is sorted against all other candidates with all their data. Maybe some way of grouping or naming the ranges to then sort on a given value in the group or range.

Does anyone have any ideas?

Admin Note: Screenshot has been removed upon member's request due to sensitive information. As it is also explained in the original question above, cells are vertically merged and table needs to be sorted properly.

Last edited by a moderator:

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### yky

##### Well-known Member
You can do it with VBA. I have done it before with a sheet somewhat similar to yours. In your case, it may be necessary to convert the Excel table to range first, sort it, then, convert it back to an Excel table.

Can you write VBA scripts? If you can, here is the idea:
1. convert the Excel table to range,
2. un-merge everything,
3. insert two columns in the sheet. They can be anywhere in the sheet but it'd be easier if inserted before Col. A. I'll call them "new A" and "new B",
4. fill new A with overall,
5. fill new B with row number,
6. sort first by new A then new B. Sorting by new A is essentially sorting overall. Sorting by new B will keep the rows in its original order in the merged group.
7. re-merge cells,
8. delete new A and new B,
9. convert the range to an Excel table and it's done.

Last edited:

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,117
Messages
5,835,484
Members
430,358
Latest member
zzc1128

### 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.

### Which adblocker are you using?

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

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