+ Reply to Thread
Results 1 to 10 of 10

Color Indexing

  1. #1
    Registered User
    Join Date
    02-09-2006
    Posts
    51

    Color Indexing

    Is it possible to have a formula check the color index of a cell?

    Example if A1 color index = 6 then X

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by PBANKS
    Is it possible to have a formula check the color index of a cell?

    Example if A1 color index = 6 then X
    Please Login or Register  to view this content.
    works for me.

    ---

  3. #3
    Forum Contributor
    Join Date
    09-04-2006
    Location
    Yorkshire, England
    Posts
    267
    Yep.

    heres the simplist you can modify, it checks if the cel color is yellow and if it is selects b1

    Sub ooo()
    If Range("a1").Interior.ColorIndex = 6 Then
    Range("B1").Select
    End If
    End Sub

    For reference heres a small list of the color number index

    1 = black
    2 = white
    3 = red
    4 = bright green
    5 = blue
    6 = yellow
    7 = pink
    8 = bright blue
    9 = brown
    11 = dark blue
    13 = teal


    hope it helps
    JR
    Versions
    Mac OS X 'Leopard'
    Mac MS Office Excel 2004
    Windows XP
    MS Excel 2002
    MS Excel 2003

  4. #4
    Registered User
    Join Date
    02-09-2006
    Posts
    51
    Thanks, I will try this in just a bit.

  5. #5
    Registered User
    Join Date
    02-09-2006
    Posts
    51
    Sorry, I actually wanted this for a simple formula that is in the cell itself. I was in a hurry earlier and did not pay attention. I believe that I have done this before, but I just can not figure it out.

  6. #6
    Forum Contributor
    Join Date
    03-24-2004
    Location
    Edam Netherlands
    Posts
    181
    Function CINDEX(ByVal rRange as Range) as integer

    If rRange.Cells.count = 1 then CINDEX = rRange.Font.ColorIndex

    End Function

    If you put something like this in a module you can use the function on your worksheet

  7. #7
    Registered User
    Join Date
    02-09-2006
    Posts
    51
    Sorry, but I am having one of those moments where I just do not understand. How do I use it in my formula?

    If A1 = X then CINDEX A1 = 2?

  8. #8
    Registered User
    Join Date
    02-09-2006
    Posts
    51
    Does anyone know the magic to this, I can not figure it out. I see where it shows up in the functions, but how do I make use of it?

  9. #9
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    An alternative way that doesn't use VBA is to make use of an XLM4 macro function:

    1.Go Insert>Name>Define and name the formula you are about to create CellCol
    2. In the refers to box type:

    =GET.CELL(63,OFFSET(INDIRECT("RC",FALSE),0,-1))

    and click OK.

    3. Now, back in your worksheet in the cell to the immeriate right of the one you want to return the color index for, type

    =CellCol

    and hit return. It should return a value - you can refer to the value list that JR@SGC provided you with for what the numbers mean.

    Incidentally, the UDF code (which goes into a standard module) can be used in a cell like any other:


    =CINDEX(A1)

    to return the color index of cell A1.

    Hope this helps!

    Richard

  10. #10
    Registered User
    Join Date
    02-09-2006
    Posts
    51
    Thanks Richard, that works. The only problem is that I do not need it right next to the cell. I tried what KaaK suggested, but it gives the same results for every cell I test. I really appreciate everyones help, this gets it one step closer.

    Thank You

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1