+ Reply to Thread
Results 1 to 5 of 5

cells interior/color index

Hybrid View

  1. #1
    Registered User
    Join Date
    01-10-2006
    Posts
    1

    cells interior/color index

    How/Where do I get the color index?
    I used the names of the colors:

        For i = 1 To grpnr
            Select Case D1(i)
            Case Cells.Interior("Light Orange")
                grpsize(i) = 6
            Case Cells.Interior("Aqua")
                grpsize(i) = 4
            Case Cells.Interior("Plum")
                grpsize(i) = 3
            Case Cells.Interior("Rose")
                grpsize(i) = 2
            Case Else
                MsgBox "error in grouping color"
            End Select
        Next i
    only to return error.

  2. #2
    Yngve
    Guest

    Re: cells interior/color index

    Hi tandavina

    The best way for you to learn something like this (the same as for
    everyone
    - myself included) is to use the Macro recorder on the Tools...Macros
    menu

    This is always the best way to start when you don't know what objects
    you
    need...

    When you have finished recording the actions that you need the code
    for,
    click Stop on the Tools..Macros menu, and use ALT-F8 to show the Macros
    dialog.

    Select the new macro that you just recorded, and choose 'Edit'

    then you can see the code that has been recorded, and this will help
    you see
    what objects are used, and give you a head start.

    If you are still stuck modifying the code, let uis know and we'll help
    ....

    Regards Yngve


  3. #3
    Gary''s Student
    Guest

    RE: cells interior/color index

    1. enter this tiny macro:

    Sub Macro1()
    MsgBox (Selection.Interior.ColorIndex)
    End Sub

    2. set the background color of any cell to any color and select that cell

    3. run the macro to get the number

    So if you set a cell t light orange, you would see 45
    --
    Gary''s Student


    "tandavina" wrote:

    >
    > How/Where do I get the color index?
    > I used the names of the colors:
    >
    >
    > Code:
    > --------------------
    > For i = 1 To grpnr
    > Select Case D1(i)
    > Case Cells.Interior("Light Orange")
    > grpsize(i) = 6
    > Case Cells.Interior("Aqua")
    > grpsize(i) = 4
    > Case Cells.Interior("Plum")
    > grpsize(i) = 3
    > Case Cells.Interior("Rose")
    > grpsize(i) = 2
    > Case Else
    > MsgBox "error in grouping color"
    > End Select
    > Next i
    > --------------------
    >
    >
    > only to return error.
    >
    >
    > --
    > tandavina
    > ------------------------------------------------------------------------
    > tandavina's Profile: http://www.excelforum.com/member.php...o&userid=30334
    > View this thread: http://www.excelforum.com/showthread...hreadid=511457
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: cells interior/color index

    See http://tinyurl.com/8h9lw, Peter and I cover most there.

    Your code should look like

    Cells.Interior.Colorindex = xlCILight Orange

    although your case statement looks odd to me, so perhaps it should say

    Select Case D1(i)
    Case xlCILight Orange
    grpsize(i) = 6

    etc.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "tandavina" <tandavina.23448y_1139741101.6811@excelforum-nospam.com> wrote
    in message news:tandavina.23448y_1139741101.6811@excelforum-nospam.com...
    >
    > How/Where do I get the color index?
    > I used the names of the colors:
    >
    >
    > Code:
    > --------------------
    > For i = 1 To grpnr
    > Select Case D1(i)
    > Case Cells.Interior("Light Orange")
    > grpsize(i) = 6
    > Case Cells.Interior("Aqua")
    > grpsize(i) = 4
    > Case Cells.Interior("Plum")
    > grpsize(i) = 3
    > Case Cells.Interior("Rose")
    > grpsize(i) = 2
    > Case Else
    > MsgBox "error in grouping color"
    > End Select
    > Next i
    > --------------------
    >
    >
    > only to return error.
    >
    >
    > --
    > tandavina
    > ------------------------------------------------------------------------
    > tandavina's Profile:

    http://www.excelforum.com/member.php...o&userid=30334
    > View this thread: http://www.excelforum.com/showthread...hreadid=511457
    >




  5. #5
    Ron de Bruin
    Guest

    Re: cells interior/color index

    Hi

    Run this macro on a empty sheet

    Sub ListColorIndexes()
    Dim Ndx As Integer

    For Ndx = 1 To 56
    Cells(Ndx, 1).Interior.ColorIndex = Ndx
    Cells(Ndx, 2).Value = Ndx
    Next Ndx
    End Sub


    See also
    http://www.mvps.org/dmcritchie/excel/colors.htm




    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "tandavina" <tandavina.23448y_1139741101.6811@excelforum-nospam.com> wrote in message
    news:tandavina.23448y_1139741101.6811@excelforum-nospam.com...
    >
    > How/Where do I get the color index?
    > I used the names of the colors:
    >
    >
    > Code:
    > --------------------
    > For i = 1 To grpnr
    > Select Case D1(i)
    > Case Cells.Interior("Light Orange")
    > grpsize(i) = 6
    > Case Cells.Interior("Aqua")
    > grpsize(i) = 4
    > Case Cells.Interior("Plum")
    > grpsize(i) = 3
    > Case Cells.Interior("Rose")
    > grpsize(i) = 2
    > Case Else
    > MsgBox "error in grouping color"
    > End Select
    > Next i
    > --------------------
    >
    >
    > only to return error.
    >
    >
    > --
    > tandavina
    > ------------------------------------------------------------------------
    > tandavina's Profile: http://www.excelforum.com/member.php...o&userid=30334
    > View this thread: http://www.excelforum.com/showthread...hreadid=511457
    >




+ 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