View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JVANWORTH JVANWORTH is offline
external usenet poster
 
Posts: 50
Default Functions expert€¦€¦€¦numbering 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