Macro that sorts data with blanks at the bottom

abbruno

New Member
Joined
Nov 13, 2012
Messages
6
I am trying to add a macro that finds a dynamic range (number of rows changing with different data sets) sorts column B, then column A, moving blanks to the bottom. My dilemma is as follows:

I have a template with formulas that cannot be changed (I cannot paste special values, or clear the cells). Column A includes HLOOKUP formulas for cells A14:A120. Column B includes VLOOKUP formulas for cells B14:B120. The different data sets I pull in have different numbers of lines, which is why I need to maintain the formulas. However, I cannot seem to find a way to accurately sort column B first from smallest to largest and then column A from smallest to largest. In all data sets there will be at least a few blank lines that I need to move to the bottom. However, due to the formulas within the cells (column A returns a value of 0 and column B returns a value of “ “), excel does not recognize them as being blank. Here is a sample data set.


Branch S&C Group
77770000583-DOWNERS GROVE BRANCHMWBF2
77770000585-CHICAGO RIVER BRANCHMWBF1
77770000587-WEST TOWN BRANCHMWBF1
77770000941-DES PLAINES 750 LEE BRANCHMWBF1
77770000942-DES PLAINES OAKTON BRANCHMWBF1
77770000944-LINCOLN PARK BRANCHMWBF2
77770002244-ROSEMONT BRANCH (ILLI3103)MWBF2
77770002247-VERNON HILLS BRANCH (ILLI3168)MWBF2
77770002250-ELK GROVE BRANCH (ILLI3104)MWBF2
77770002253-NILES BRANCH (ILLI3181)MWBF2
77770002258-DEERFIELD BRANCH (ILLI3165)MWBF1
77770002267-ST. CHARLES, IL
77770002268-FOX LAKE BRANCH (ILLI3169)MWBF1
77770002271-CRYSTAL LAKE BRANCH (ILLI3180)MWBF2
77770002272-ALGONQUIN, IL
77770002274-WHEELING BRANCH (ILLI3183)MWBF2
77770002278-HIGHWOOD BRANCH (ILLI3160)MWBF2
77770002281-MUNDELEIN BRANCH (ILLI3163)MWBF2
77770002284-PALATINE BRANCH (ILLI3164)MWBF2
77770002291-25 E WASHINGTON BRANCH-ILMWBF1
77770002294-PARK FOREST BRANCH (ILLI3101)MWBF1
77770002297-BURBANK BRANCH (ILLI3102)MWBF2
77770002301-BELMONT BRANCH (ILLI3116)MWBF1
77770002304-EDGEWATER BRANCH (ILLI3119)MWBF1
77770002307-IRVING PARK ILMWBF2
77770002313-OAK PARK BRANCH (ILLI3111)MWBF1
77770002316-AUSTIN BRANCH (ILLI3113)MWBF2
77770002324-ELMHURST BRANCH (ILLI3144)MWBF1
77770002333-NORTHLAKE BRANCH (ILLI3148)MWBF2
77770002337-GENEVA BRANCHMWBF1
77770002340-EAST GENEVA BRANCH (ILLI3138)MWBF2
77770002350-ROOSEVELT RD BRANCH (ILLI3153)MWBF2
77770002353-GLEN ELLYN MAIN OFFICEMWBF1
77770002360-NAPERVILLE BRANCH (ILLI3131)MWBF1
77770002366-MARKET MEADOWS BRNCH(ILLI3133)MWBF1
77770002369-BOLINGBROOK BRANCH (ILLI3134)MWBF1
77770002372-63RD STREET BRANCHMWBF2
77770002378-WHITE EAGLE BRANCH (ILLI3135)MWBF1
77770003974-ROOKERY BLDG-ILMWBF2
77770007140-LEMONT ILMWBFP
77770007141-AUSTIN-DIVISION ST ILMWBFP
77770007142-COSMOPOLITAN ILMWBFP
77770007143-EAST SIDE ILMWBFP
77770007144-ENGLEWOOD ILMWBFP
77770007146-MILWAUKEE AVE ILMWBFP
77770007147-MOUNT GREENWOOD ILMWBFP
77770007148-NORWOOD PARK ILMWBFP
77770007149-PULLMAN ILMWBFP
77770007150-SOUTH CHICAGO ILMWBFP
77770007151-WEST GARFIELD ILMWBFP
77770007152-CICERO ILMWBFP
77770007156-HINSDALE ILMWBFP
77770007157-LISLE ILMWBFP
77770007159-MAYWOOD ILMWBFP
77770007161-NORTH OAK PARK ILMWBFP
77770007162-OAK PARK-MADISON ST ILMWBFP
77770007163-CHICAGO HEIGHTS ILMWBFP
77770007164-DOLTON ILMWBFP
77770007165-FLOSSMOOR ILMWBFP
77770007166-HOMEWOOD ILMWBFP
77770007167-LANSING ILMWBFP
77770007168-SAUK VILLAGE ILMWBFP
77770007170-WEST DUNDEE ILMWBFP
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

<tbody>
</tbody>

In this case, I would like St. Charles & Algonquin to be at the bottom because column B is blank.

Can anyone help me?! Thank you very much!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I wanted to add an attachment the first time, but couldn't figure out how. Can someone tell me the easiest way to share a link to my sample file if it is not something posted online? Sorry, I'm new at this...
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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