How Do I Do A Custom Sort

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
I want to sort a file by a particular column first. I need it to be sorted with a particular word first but that word may be anywhere within the cell.

Obviously the normal sort would do it by the first letter of the first word in the cell either A-Z or Z-A. But I need it to look for a particular word in the cell and have that first. Is it possible?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
If you don't want to use VBA, you'll have to create a new (hidden) column extracting the data and then sorting by that column. Are you opposed to this?
The word within the cell that you want to sort by - is it then just a regular alphabetical sort, or a custom sort order (e.g. days of the week)?
 
Upvote 0
If there is a vba code that I can use then I would be happy with that, I can adapt it to use on different files then. Would you know how to write it? It needs to highlight the whole sheet and sort by column C first A-Z then column AD A-Z looking for the word 'leads' first. Thanks. (There is a header column in row 1)
 
Upvote 0
So any cell with leads in it goes first? Any particular order within that? Or it's just leads and no leads?
I don't know anything about VBA, but I can write you a one-column formula to sort by if you're interested.
 
Upvote 0
VBA To Do A Custom Sort

There are several columns either side that would need including so sorting by the single column would be no good, thanks. It goes from A right over to about AJ.
 
Last edited:
Upvote 0
Re: VBA To Do A Custom Sort

I wasn't clear enough. You'll sort all your data; you'll just have one extra column which you can hide.
To be clear, you want to first sort on column C, regular A-Z (nothing to do with "leads"). Then second-level sorting on column AD, anything with "leads" contained in it comes first. Is that right? Two levels of sorting?
 
Upvote 0
Re: VBA To Do A Custom Sort

Yes please as long as it takes all the other columns with it in the sort. If you need a helper column its probably better if column AL is used beacuse I dont want columns inserted etc amongst the other columns.
 
Upvote 0
Re: VBA To Do A Custom Sort

Ok, so put this in cell AL2:

=--ISNUMBER(FIND("leads",AD2))

and drag down until the bottom of your data.

Then sort on column C alphabetically, and then on column AL on values, largest to smallest.

Then highlight column AL, right-click>Hide.
 
Upvote 0
Re: VBA To Do A Custom Sort

Thanks but they all return zero?
 
Upvote 0
Re: VBA To Do A Custom Sort

Impossible, unless none of the cells actually contain the word "leads". Are you sure you have the ranges correct?
 
Upvote 0

Forum statistics

Threads
1,215,263
Messages
6,123,956
Members
449,135
Latest member
jcschafer209

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