Sort by cities

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
1,012
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Hi all,

Is it possible with Excel VBA to sort data according to the text in record, in this case city, above

Whitsett Ave (N. Hollywood)
Victory Blvd (N. Hollywood)
Kenneth Rd (Burbank)
Alameda Ave (Burbank)
Kenneth Rd (Burbank)
Central Ave (Glendale)
Central Ave (Glendale)

To get:

Alameda Ave (Burbank)
Kenneth Rd (Burbank)
Kenneth Rd (Burbank)
Central Ave (Glendale)
Central Ave (Glendale)
Victory Blvd (N. Hollywood)
Whitsett Ave (N. Hollywood)

Thank you in advance
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
With a helper column it shouldn't be that difficult at all. All you need to do is split the column, sort both columns according to that and then delete the helper column (if you must). I can't write you a working code because with VBA you need to know the worksheet structure etc.

If you have Power Query ( originally a free add in for Excel 2010, later renamed "Get & Transform" and put to the Data tab of the ribbon) you can do the same without VBA.
 
Upvote 0
You don't even need to split the columns, just add a helper column with the following formula (for an entry in cell A2):
Code:
=MID(A2,FIND("(",A2),LEN(A2))
You can then sort by the helper column (and even hide it, if you do not want to see it).
 
Upvote 0
You are welcome.
Glad we were able to help.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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