Sort "Z to A" but keep "blank" values at bottom of list

smking204

New Member
Joined
Jan 28, 2021
Messages
32
Office Version
  1. 365
Platform
  1. Windows
I want to build a macro to sort rows 2-50 by column D, descending (Z-A). But Column D contains formulas that remain blank unless sufficient data appears in columns A and B. How can I sort rows 2-50 in descending order without getting the "empty" cells appearing on top and pushing all the relevant cells to the bottom?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
How about something like this... Just formulas, no VBA.

XL
NOPQR
1A1O15
2B M13
3C3K11
4D I9
5E5G7
6F E5
7G7C3
8H A1
9I9B
10J D
11K11F
12L H
13M13J
14N L
15O15N
Data
Cell Formulas
RangeFormula
Q1:R15Q1=LET(table,N1:O15,sort_col,O1:O15,sb,IF(sort_col="",-1,sort_col),SORTBY(table,sb,-1))
O1:O15O1=IF(MOD(ROW(),2)=0,"",ROW())
Dynamic array formulas.
 
Upvote 0
How about something like this... Just formulas, no VBA.

XL
NOPQR
1A1O15
2B M13
3C3K11
4D I9
5E5G7
6F E5
7G7C3
8H A1
9I9B
10J D
11K11F
12L H
13M13J
14N L
15O15N
Data
Cell Formulas
RangeFormula
Q1:R15Q1=LET(table,N1:O15,sort_col,O1:O15,sb,IF(sort_col="",-1,sort_col),SORTBY(table,sb,-1))
O1:O15O1=IF(MOD(ROW(),2)=0,"",ROW())
Dynamic array formulas.
Not a fan. Thanks though. I've got it set up the way I want it, and usually I do the sort myself by manually selecting the relevant range (usually about 15 to 20 rows) and going to Data > Sort, but I want to create a button to do that automatically, and apply it to all rows through 50, since the length of the list changes according to row A. Just looking for a way to make sure the empty rows remain at the bottom when I sort rows 2-50.
 
Upvote 0

Forum statistics

Threads
1,215,810
Messages
6,127,015
Members
449,351
Latest member
Sylvine

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