# Keep dynamic data sorted

#### nelsok

##### Board Regular
The only thing i can think of to make my dynamic data always be sorted is to use a formula to sort it.

Does anyone have a formula for sorting data in descending order?

### Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

#### fairwinds

##### MrExcel MVP
Hi,

Try:

C2: =SUMPRODUCT(--(A2<\$A\$2:\$A\$10))+COUNTIF(\$A\$2:A2,A2)
D2: =INDEX(\$A\$2:\$A\$10,MATCH(ROW()-ROW(\$D\$1),\$C\$2:\$C\$10,0))

Both dragged down.
Book1
ABCD
1List1RankSorted list
2q3x
3a6t
4c4q
5x1c
6c5c
7a7a
8259a
9t2a
10a825
Sheet1

#### nelsok

##### Board Regular
this will work but the only issue I have is that there are other cells associated with the values being sorted... for example a1 has a name b1 has revenue and c1 has expenditure and d1 has b1/c1...

I would want to sort by d1 but still have the correct data associated with each cell.

is this possible?

#### fairwinds

##### MrExcel MVP
Sure.

Column C is base line. Just use the same formula as in column D, copied to further columns, to refere to the other columns you would like to sort along.

#### nelsok

##### Board Regular
This is working perfectly. However is it possible to get the cells with "" to be at the end of the sort and not the begining?

#### fairwinds

##### MrExcel MVP
Not sure what you mean. Cells with "", formula blanks will end up at the end. See:
Book1
ABCD
1
2Q5Y
3W2W
4 8U
5R4R
6 9Q
7Y1O
8U3I
9I7
10O6
Sheet1

#### fairwinds

##### MrExcel MVP
I see.

="" is concidered "larger" than a number.

In my exhibit above, replace the formula in C2 with

=IF(A2<>"",COUNTIF(\$A\$2:\$A\$10,">"&A2)+COUNTIF(\$A\$2:A2,A2),COUNTA(\$A\$2:\$A\$10)+1-COUNTIF(\$A\$2:A2,A2))+IF(ISNUMBER(A2),COUNTA(\$A\$2:\$A\$10)-COUNT(\$A\$2:\$A\$10)-COUNTBLANK(\$A\$2:\$A\$10))

#### fairwinds

##### MrExcel MVP
I don't see why you should need to take it away. If you have only numbers it should work but with a mix of text and numbers and formula blanks, I get an error without the 1.

Replies
16
Views
489
Replies
1
Views
295
Replies
5
Views
328
Replies
4
Views
830
Replies
3
Views
469

Threads
1,171,719
Messages
5,877,120
Members
433,233
Latest member
Haripriya

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

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