Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 50
Default Functions expertnumbering random condition in a column

I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs to
be the order in which the color was selected relative to equivalent colors.
So the first red selected will be Red-1, next red selected will be
Red-2. This will happen to for each color. i.e..

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Functions expert...numbering random condition in a column

=COUNTIF($A$2:A2,A2)&IF(OR(VALUE(RIGHT(COUNTIF($A$ 2:A2,A2),2))={11,12,13}),"th",IF(OR(VALUE(COUNTIF( $A$2:A2,A2))={1,2,3}),CHOOSE(RIGHT(COUNTIF($A$2:A2 ,A2)),"st
","nd ","rd "),"th "))&A2

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Functions expert...numbering random condition in a column

Maybe this entered in B1 and copied down:

=IF(A1="","",COUNTIF(A$1:A1,A1))

This will return the count of each entry.

If you want the ordinal plus the color then it's more complicated:

=IF(A1="","",COUNTIF(A$1:A1,A1)&IF(OR(MOD(COUNTIF( A$1:A1,A1),100)={11,12,13}),"th",LOOKUP(--RIGHT(COUNTIF(A$1:A1,A1)),{0,"th";1,"st";2,"nd";3, "rd";4,"th"}))&"
"&A1)

Biff

"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Functions expertnumbering random condition in a column

I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first red selected will be Red-1, next red selected will be
Red-2. This will happen to for each color. i.e..

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.


If you can do with just numbers (that is, without the "st", "nd", "rd" and
color name designations), put this formula in B1 and copy down (change the
999 so that it is larger than the largest row you expect to fill down to).

=COUNTIF($A$1:$A1,A1)

Rick

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Functions expert...numbering random condition in a column

Colour?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"T. Valko" wrote in message
...
Maybe this entered in B1 and copied down:

=IF(A1="","",COUNTIF(A$1:A1,A1))

This will return the count of each entry.

If you want the ordinal plus the color then it's more complicated:

=IF(A1="","",COUNTIF(A$1:A1,A1)&IF(OR(MOD(COUNTIF( A$1:A1,A1),100)={11,12,13}),"th",LOOKUP(--RIGHT(COUNTIF(A$1:A1,A1)),{0,"th";1,"st";2,"nd";3, "rd";4,"th"}))&"
"&A1)

Biff

"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.







  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 50
Default Functions expert...numbering random condition in a column

just brilliant

"T. Valko" wrote:

Maybe this entered in B1 and copied down:

=IF(A1="","",COUNTIF(A$1:A1,A1))

This will return the count of each entry.

If you want the ordinal plus the color then it's more complicated:

=IF(A1="","",COUNTIF(A$1:A1,A1)&IF(OR(MOD(COUNTIF( A$1:A1,A1),100)={11,12,13}),"th",LOOKUP(--RIGHT(COUNTIF(A$1:A1,A1)),{0,"th";1,"st";2,"nd";3, "rd";4,"th"}))&"
"&A1)

Biff

"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 50
Default Functions expert...numbering random condition in a column

just brilliant

"Bob Phillips" wrote:

=COUNTIF($A$2:A2,A2)&IF(OR(VALUE(RIGHT(COUNTIF($A$ 2:A2,A2),2))={11,12,13}),"th",IF(OR(VALUE(COUNTIF( $A$2:A2,A2))={1,2,3}),CHOOSE(RIGHT(COUNTIF($A$2:A2 ,A2)),"st
","nd ","rd "),"th "))&A2

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Functions expert...numbering random condition in a column

???

Biff

"Bob Phillips" wrote in message
...
Colour?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"T. Valko" wrote in message
...
Maybe this entered in B1 and copied down:

=IF(A1="","",COUNTIF(A$1:A1,A1))

This will return the count of each entry.

If you want the ordinal plus the color then it's more complicated:

=IF(A1="","",COUNTIF(A$1:A1,A1)&IF(OR(MOD(COUNTIF( A$1:A1,A1),100)={11,12,13}),"th",LOOKUP(--RIGHT(COUNTIF(A$1:A1,A1)),{0,"th";1,"st";2,"nd";3, "rd";4,"th"}))&"
"&A1)

Biff

"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The
example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.







  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Functions expert...numbering random condition in a column

<quote If you want the ordinal plus the color then it's more complicated:
</quote


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bob Phillips" wrote in message
...
Colour?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"T. Valko" wrote in message
...
Maybe this entered in B1 and copied down:

=IF(A1="","",COUNTIF(A$1:A1,A1))

This will return the count of each entry.

If you want the ordinal plus the color then it's more complicated:

=IF(A1="","",COUNTIF(A$1:A1,A1)&IF(OR(MOD(COUNTIF( A$1:A1,A1),100)={11,12,13}),"th",LOOKUP(--RIGHT(COUNTIF(A$1:A1,A1)),{0,"th";1,"st";2,"nd";3, "rd";4,"th"}))&"
"&A1)

Biff

"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The
example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.







  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Functions expert...numbering random condition in a column

Color = the text string red, white, etc.

Biff

"Bob Phillips" wrote in message
...
<quote If you want the ordinal plus the color then it's more complicated:
</quote


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Bob Phillips" wrote in message
...
Colour?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"T. Valko" wrote in message
...
Maybe this entered in B1 and copied down:

=IF(A1="","",COUNTIF(A$1:A1,A1))

This will return the count of each entry.

If you want the ordinal plus the color then it's more complicated:

=IF(A1="","",COUNTIF(A$1:A1,A1)&IF(OR(MOD(COUNTIF( A$1:A1,A1),100)={11,12,13}),"th",LOOKUP(--RIGHT(COUNTIF(A$1:A1,A1)),{0,"th";1,"st";2,"nd";3, "rd";4,"th"}))&"
"&A1)

Biff

"JVANWORTH" wrote in message
...
I need to number random conditions as they occur in a column. The
example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B
needs to
be the order in which the color was selected relative to equivalent
colors.
So the first "red" selected will be "Red-1, next "red" selected will be
"Red-2". This will happen to for each color. i.e.....

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.











  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Functions expertnumbering random condition in a column

I need to number random conditions as they occur in a column. The
example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first red selected will be Red-1, next red selected will be
Red-2. This will happen to for each color. i.e..

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.


If you can do with just numbers (that is, without the "st", "nd", "rd" and
color name designations), put this formula in B1 and copy down (change the
999 so that it is larger than the largest row you expect to fill down to).

=COUNTIF($A$1:$A1,A1)


Alright, if the OP wants the ordinal suffixes and color, then here is my
attempt at a formula....

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBST ITUTE(SUBSTITUTE(COUNTIF($A$1:$A1,A1)&"th
"&A1,"1th","1st"),"2th","2nd"),"3th","3rd"),"11st" ,"11th"),"12nd","12th"),"13rd","13th")

It comes in midway (in length) between the other two submitted formulas.

Rick

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Functions expert...numbering random condition in a column

Color = the text string red, white, etc.

Colour <== Color .... Notice the "u"... I think the comment was a British
"thing".

{OT: I responded to your comment in the "m.p.e.misc" thread}

Rick

  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Functions expert...numbering random condition in a column

{OT: I responded to your comment in the "m.p.e.misc" thread}

Yesh, I saw it. I'm still playing with that one. You're starting to get over
my head VBA-wise (not one of my strengths).

It would be nice if the OP reponded so we would know what direction to go
with that.

Biff

"Rick Rothstein (MVP - VB)" wrote in
message ...
Color = the text string red, white, etc.


Colour <== Color .... Notice the "u"... I think the comment was a British
"thing".

{OT: I responded to your comment in the "m.p.e.misc" thread}

Rick



  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Functions expert...numbering random condition in a column

{OT: I responded to your comment in the "m.p.e.misc" thread}

Yesh, I saw it. I'm still playing with that one. You're starting to get
over my head VBA-wise (not one of my strengths).


I'd be more than happy to answer any question you may have about that code,
so don't hestiate to ask (over in the other thread, of course<g).

It would be nice if the OP reponded so we would know what
direction to go with that.


That was always a frustration over in the compiled VB newsgroups (where I
have volunteered for the last 6 or 7 years)... nebulous questions asked, one
or more answers provided, silence from the OP. Being that it is happening
here, I guess this is a universal newsgroup affliction.

Rick

  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 50
Default Functions expertnumbering random condition in a column

I posted a color (colour) issue later:
try this:-

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) _
Is Nothing Then Exit Sub
Select Case Target.Value
Case "A" To "E"
icolor = 3
Case "F" To "J"
icolor = 41
Case "K" To "O"
icolor = 4
Case "P" To "T"
icolor = 6
Case Else
End Select
Target.Interior.ColorIndex = icolor
End Sub


"JVANWORTH" wrote:

I need a cell to change into four (4) different colors if a specific
condition is met. For example if A1 matches a text value A thru E I need
red, if its a F thru J then blue, K thru O then green, P thru T
then yellow.

Im struggling with the set up of this requirement.



"Rick Rothstein (MVP - VB)" wrote:

I need to number random conditions as they occur in a column. The
example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first red selected will be Red-1, next red selected will be
Red-2. This will happen to for each color. i.e..

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.


If you can do with just numbers (that is, without the "st", "nd", "rd" and
color name designations), put this formula in B1 and copy down (change the
999 so that it is larger than the largest row you expect to fill down to).

=COUNTIF($A$1:$A1,A1)


Alright, if the OP wants the ordinal suffixes and color, then here is my
attempt at a formula....

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBST ITUTE(SUBSTITUTE(COUNTIF($A$1:$A1,A1)&"th
"&A1,"1th","1st"),"2th","2nd"),"3th","3rd"),"11st" ,"11th"),"12nd","12th"),"13rd","13th")

It comes in midway (in length) between the other two submitted formulas.

Rick




  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tom tom is offline
external usenet poster
 
Posts: 570
Default Functions expertnumbering random condition in a column

Thanks Rick.
--
T in Vegas


"Rick Rothstein (MVP - VB)" wrote:

I need to number random conditions as they occur in a column. The example
show is in its simplest form.

Column A is a list of colors that are selected randomly. Column B needs
to
be the order in which the color was selected relative to equivalent
colors.
So the first red selected will be Red-1, next red selected will be
Red-2. This will happen to for each color. i.e..

A B
1 red 1 1st red
2 blue 1 1st blue
3 red 2 2nd red
4 red 3 3rd red
5 white 1 1st white
6 blue 2 2nd blue

When the order changes I want the spread to adjust accordingly.


If you can do with just numbers (that is, without the "st", "nd", "rd" and
color name designations), put this formula in B1 and copy down (change the
999 so that it is larger than the largest row you expect to fill down to).

=COUNTIF($A$1:$A1,A1)

Rick


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting entries in column based on condition in another column RobertR Excel Worksheet Functions 1 February 8th 07 03:54 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
Help with Random Functions CIL Excel Worksheet Functions 6 August 15th 06 03:04 AM
Generation of random numbers and sum of those with a condition ramana Excel Worksheet Functions 11 October 5th 05 05:01 AM
random numbering Gloria Excel Worksheet Functions 1 July 20th 05 01:17 AM


All times are GMT +1. The time now is 11:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"