Sorting with a formula

HWL

Active Member
Joined
Dec 1, 2009
Messages
462
Okay, so I have a list of numbers generated by a formula that I want to sort in numberical order another column using an array formula.

THE PROBLEM, the piece of code I found that can do this breaks because it is counting the blank cells as not blank because they contain a formula.

I want to take my column of numbers in column B and then sort them numerically in column C.

The code I have so far which works only if the numbers in B are typed in, it breaks if there are blanks generated by a formula
:
=IF(ISERROR(INDEX($B$3:$B$100, MATCH(SMALL(IF(ISBLANK($B$3:$B$100), "", COUNTIF($B$3:$B$100, "<"&$B$3:$B$100)+1), ROW(1:1)), IF(ISBLANK($B$3:$B$100), "", COUNTIF($B$3:$B$100, "<"&$B$3:$B$100)+1), 0))),"",INDEX($B$3:$B$100, MATCH(SMALL(IF(ISBLANK($B$3:$B$100), "", COUNTIF($B$3:$B$100, "<"&$B$3:$B$100)+1), ROW(1:1)), IF(ISBLANK($B$3:$B$100), "", COUNTIF($B$3:$B$100, "<"&$B$3:$B$100)+1), 0))) USE CTRL+SHIFT+ENTER

Assistance on this is greatly appreciated. I know the issue is with ISBLANK and with COUNTIF
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try replacing ALL instances of

ISBLANK(range)
with
(range="")
or
(LEN(range)=0)

Hi there, I'm still trying to use this piece of code to sort text, but it seems there is still an issue with countif counting blank cells that contain formulas. Any ideas?
 
Upvote 0
Hi there, I'm still trying to use this piece of code to sort text, but it seems there is still an issue with countif counting blank cells that contain formulas. Any ideas?

Ah, it was breaking if the entry was not unique. I fixed it. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

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