Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I wish I could...

955 views
Skip to first unread message

gmisi

unread,
Oct 11, 2006, 7:33:02 PM10/11/06
to
I wish I could come up with a combination of functions to automate the
sorting (in ascending or desc. order) columnA (the lenght is different on
each sheet) containing multiple text and/or number values (even blank ones)
so, that in colF will be the sorted list of unique values and colG will show
how many times this value figures in the unsorted list ---- but I can't, so I
ask for your kind help.

Thanks in advance

Max

unread,
Oct 11, 2006, 9:55:01 PM10/11/06
to
Venturing some thoughts ..

Assuming source data running in A1 down, and what's required is an
auto-ascending sort of only the unique source data items in col F, with a
corresponding occurences count in col G

Put in E1:
=IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+ROW()/10^10,IF(ISTEXT(A1),CODE(LEFT(A1))+ROW()*10^10))))

Put in G1:
=IF(ROW()>COUNT(E:E),"",INDEX(A:A,MATCH(SMALL(E:E,ROW()),E:E,0)))

Put in H1:
=IF(F1="","",COUNTIF(A:A,F1))

Then select E1:H1, copy down to cover the max expected extent of source data
in col A. Hide away col E. Col F will yield the list of uniques from col A,
sorted in ascending order*, while col G returns the corresponding count of
the uniques' occurences.
*Numbers (either real or text numbers) will be sorted ahead of alphas
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---

Biff

unread,
Oct 11, 2006, 10:00:08 PM10/11/06
to
See this sample file:

http://cjoint.com/?kmd6wEsiac

Biff

"Max" <demec...@yahoo.com> wrote in message
news:91F8BA64-A907-401B...@microsoft.com...

Biff

unread,
Oct 11, 2006, 10:09:08 PM10/11/06
to
This doesn't work on my sample file:

http://cjoint.com/?kmehWBQGic

Biff

"Max" <demec...@yahoo.com> wrote in message
news:91F8BA64-A907-401B...@microsoft.com...

Max

unread,
Oct 11, 2006, 10:16:01 PM10/11/06
to
Sorry, some typos in the preceding response ..

Lines
> Put in G1: ..
> Put in H1: ..
> Then select E1:H1 ...

should read as
> Put in F1: ..
> Put in G1: ..
> Then select E1:G1 ...

And for an auto-descending sort of only the unique source data items in col
F ..
try these ..

Put instead in E1:
=IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+0,IF(ISTEXT(A1),CODE(LEFT(A1))*10^10-ROW()))))

Put instead in F1:
=IF(ROW()>COUNT(E:E),"",INDEX(A:A,MATCH(LARGE(E:E,ROW()),E:E,0)))

(no change to G1's formula)

Then just copy E1:G1 down as before to cover the max expected extent of

source data in col A. Hide away col E. Col F will yield the list of uniques
from col A,

sorted in descending order*, while col G returns the corresponding count of
the uniques' occurences.
*Alphas will be sorted ahead of numbers (either real or text numbers)

Max

unread,
Oct 11, 2006, 10:25:43 PM10/11/06
to
Correction to earlier formula ...
(with thanks to Biff for detecting this)

> Put in E1:
> =IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+ROW()/10^10,IF(ISTEXT(A1),CODE(LEFT(A1))+ROW()*10^10))))

should instead be:

Put in E1:
=IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+0,IF(ISTEXT(A1),CODE(LEFT(A1))*10^10+ROW()))))

Max

unread,
Oct 11, 2006, 10:27:52 PM10/11/06
to
Biff, thanks for detecting this

Correction to earlier formula ...

> Put in E1:
> =IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+ROW()/10^10,IF(ISTEXT(A1),CODE(LEFT(A1))+ROW()*10^10))))

should instead be:
Put in E1:
=IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+0,IF(ISTEXT(A1),CODE(LEFT(A1))*10^10+ROW()))))


--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---

"Biff" <biffi...@comcast.net> wrote in message
news:OOSznNa7...@TK2MSFTNGP03.phx.gbl...

Max

unread,
Oct 11, 2006, 10:34:55 PM10/11/06
to
Biff,

For the benefit of the archives and future readers, think you should also
consider posting your suggestion in text besides providing the link to the
sample file (that's what I do <g>). The cjoint link is transient and would
expire eventually (after 14 days ?), so future readers would not derive the
benefit of your response.


--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---

"Biff" <biffi...@comcast.net> wrote in message

news:%23weQmIa...@TK2MSFTNGP02.phx.gbl...

Biff

unread,
Oct 11, 2006, 11:48:36 PM10/11/06
to
The formulas are too complicated and will scare people off! Not only that,
I'm a one finger typer and sometimes it takes forever to explain my posts.

Personally, I would use Data>Sort and then Data>Filter>Advanced Filter to do
this. Maybe even record it as a macro.

Biff

"Max" <demec...@yahoo.com> wrote in message

news:OoQ9vca7...@TK2MSFTNGP05.phx.gbl...

Max

unread,
Oct 12, 2006, 1:17:37 AM10/12/06
to
"Biff" <biffi...@comcast.net> wrote

> The formulas are too complicated and will scare people off!

How can anything which works be scary? More a work of fine art to appreciate
rather than anything to be scared about. The complicated looking parts of it
perhaps might take a little more effort on the OP's / readers' part to study
and understand how it works so that one could readily adapt it to suit or
cross apply it to other similar situations ..

> I'm a one finger typer and sometimes it takes forever to explain my posts.

.. tsk, tsk, lame excuse there <g>. I've seen many of your posts where you
had patiently explained your complex formulas very well in your responses.

> Personally, I would use Data>Sort and then Data>Filter>Advanced Filter to
> do this. Maybe even record it as a macro.

well, the OP did express his / her wish for:
" .. a combination of functions to automate the sorting (in ascending or
desc. order)"

For discussions' sake, how should your formulas be modified for a descending
sort ?

For easy reference here, below is what you had suggested in your sample:

Source data assumed within A1:A21

Array-entered in B1:
=INDEX($A$1:$A$21,MATCH(MIN(COUNTIF($A$1:$A$21,"<"&$A$1:$A$21&"")+
COUNT($A$1:$A$21)*ISTEXT($A$1:$A$21)+100000*ISBLANK($A$1:$A$21)),COUNTIF($A$1:$A$21,"<"&$A$1:$A$21&"")+COUNT($A$1:$A$21)*ISTEXT($A$1:$A$21)+100000*ISBLANK($A$1:$A$21),0))

Array-entered in B2:
=INDEX($A$1:$A$21,MATCH(0,COUNTIF($A$1:$A$21,"<"&$A$1:$A$21)+COUNT($A$1:$A$21)*ISTEXT($A$1:$A$21)+100000*ISBLANK($A$1:$A$21)-SUM(COUNTIF($A$1:$A$21,"="&B$1:B1)),0))
B2 is then copied down to B21

B1:B21 yields the auto-ascending sort of the items in A1:A21

(Array-entered: Press CTRL+SHIFT+ENTER, instead of just pressing ENTER to
commit the formula)

Max

unread,
Oct 12, 2006, 1:43:17 AM10/12/06
to
Just a slight revision to the earlier criteria formulas in col E ..

For Ascending sort:
Put in E1:
=IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+0,CODE(LEFT(A1))*10^10+ROW())))

For Descending sort:
Put in E1:
=IF(A1="","",IF(COUNTIF($A$1:A1,A1)>1,"",IF(ISNUMBER(A1+0),A1+0,CODE(LEFT(A1))*10^10-ROW())))

(Other formulas remain unchanged)

gmisi

unread,
Oct 12, 2006, 4:47:02 AM10/12/06
to
Dear Max & Biff,

Let me express my sincere thanks to both of you, not only for coming up with
brilliant solutions for my posted problem, but for your enlightening attitude
to share your polished, shining knowledge, for volunteering to help us better
understand the joy of using XL.

God bless you and keep up this marvelous job!
gmisi

Max

unread,
Oct 12, 2006, 4:57:19 AM10/12/06
to
You're welcome, gmisi !
Appreciate the feedback ..

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"gmisi" <gm...@discussions.microsoft.com> wrote in message
news:0F48A13C-BFC2-4E55...@microsoft.com...

Biff

unread,
Oct 12, 2006, 2:06:35 PM10/12/06
to
>For discussions' sake, how should your formulas be modified for a
>descending sort ?

In each formula where you see "<" just change that to ">".

Biff

"Max" <demec...@yahoo.com> wrote in message

news:uYZHq3b7...@TK2MSFTNGP05.phx.gbl...

Max

unread,
Oct 12, 2006, 8:44:33 PM10/12/06
to
"Biff" wrote:
> >For discussions' sake, how should your formulas be modified for a
> >descending sort ?
>
> In each formula where you see "<" just change that to ">".

Biff, thanks !

Biff

unread,
Oct 12, 2006, 10:30:17 PM10/12/06
to
You're welcome, Max!

Biff

"Max" <demec...@yahoo.com> wrote in message

news:eXPFvDm7...@TK2MSFTNGP03.phx.gbl...

0 new messages