1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Changing the cell colour in Excell

Discussion in 'Business Applications' started by Gingerw, Jul 27, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. Gingerw

    Gingerw Thread Starter

    Joined:
    Jul 26, 2004
    Messages:
    2
    I need to be able to change the colour of a cell in Excell by typing the colour name in the cell.

    I have 12 colours that signify teams and I would like to type in a cell the word BLUE and the cell change to that colour without displaying the typed word.

    Any idea's

    (y)
     
  2. Anne Troy

    Anne Troy

    Joined:
    Feb 14, 1999
    Messages:
    11,746
    First Name:
    Anne
  3. Anne Troy

    Anne Troy

    Joined:
    Feb 14, 1999
    Messages:
    11,746
    First Name:
    Anne
    PS: Make sure you enable VBA to run by going to Tools-Macro-Security and setting it to Medium, and THEN open your workbook that now contains the code and enable macros. You only need to change the Security setting once. If you set it to low, which generally isn't recommended, you won't get the message to enable macros, they'll just automatically be enabled on your PC.
     
  4. XL Guru

    XL Guru

    Joined:
    Aug 30, 2003
    Messages:
    2,702
    Everything that Anne said, plus see DRJ's "How to use". But it could take you a while to figure the "colour numbers".

    So, colour 12 cells (e.g. H1:H12) with the colours consecutively. Then select them & run this:

    Sub Get_Colour_Numbers()
    For Each Cell In Selection
    Cell.Offset(0, 1).Value = Cell.Interior.ColorIndex
    Next Cell
    End Sub

    Rgds,
    Andy
     
  5. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Hi there,

    A simpler variation may look something like this.


    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Column <> 8 Then Exit Sub 'Column H
        Select Case Target.Value
            Case "BLACK":       Target.Interior.ColorIndex = 1:  Target.Font.ColorIndex = 2
            Case "WHITE":       Target.Interior.ColorIndex = 2:  Target.Font.ColorIndex = 0
            Case "RED":         Target.Interior.ColorIndex = 3:  Target.Font.ColorIndex = 0
            Case "GREEN":       Target.Interior.ColorIndex = 4:  Target.Font.ColorIndex = 0
            Case "BLUE":        Target.Interior.ColorIndex = 5:  Target.Font.ColorIndex = 0
            Case "YELLOW":      Target.Interior.ColorIndex = 6:  Target.Font.ColorIndex = 0
            Case "PURPLE":      Target.Interior.ColorIndex = 7:  Target.Font.ColorIndex = 0
            Case "LIGHT BLUE":  Target.Interior.ColorIndex = 8:  Target.Font.ColorIndex = 0
            Case "DARK RED":    Target.Interior.ColorIndex = 9:  Target.Font.ColorIndex = 0
            Case "DARK GREEN":  Target.Interior.ColorIndex = 10: Target.Font.ColorIndex = 0
            Case Else:          Target.Interior.ColorIndex = 0:  Target.Font.ColorIndex = 0
        End Select
    End Sub
    (Hi DB!)
     
  6. Anne Troy

    Anne Troy

    Joined:
    Feb 14, 1999
    Messages:
    11,746
    First Name:
    Anne
    Hello, firefytr! Glad to see you here!
     
  7. Gingerw

    Gingerw Thread Starter

    Joined:
    Jul 26, 2004
    Messages:
    2
    Hey everybody thanx for the help - sorry its taken a while to reply as I've been away working!!
     
  8. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452

    Great to be here! Looks like a great forum, and I hope to help where I can (which isn't much, granted)! :)
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/254933

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice