Results 1 to 5 of 5

Thread: A code to show colour in cell from list

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    7
    Rep Power
    0
    Thank you Rick

    This works just fine.Can it work without the word of the colour being visible.Just want the colour to be available

    Regards

    RK
    Attached Files Attached Files

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by rodneykaye View Post
    Thank you Rick

    This works just fine.Can it work without the word of the colour being visible.Just want the colour to be available
    I guess the easiest way is to make the font color the same as the background color...

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Count > 1 Then Exit Sub
      If Not Intersect(Target, Range("C3,E3,G3,I3,C9,E9,G9,I9,C15,E15,G15,I15")) Is Nothing Then
        Select Case Target.Value
          Case "RED": Target.Interior.ColorIndex = 3
          Case "BLUE ": Target.Interior.ColorIndex = 5
          Case "GREEN": Target.Interior.ColorIndex = 4
          Case "YELLOW": Target.Interior.ColorIndex = 6
          Case "WHITE": Target.Interior.ColorIndex = 2
        End Select
        Target.Font.ColorIndex = Target.Interior.ColorIndex
      End If
    End Sub
    I highlighted the line of code I added to do this so you can see how it is done.

Similar Threads

  1. Replies: 14
    Last Post: 10-23-2013, 01:24 PM
  2. Replies: 0
    Last Post: 09-27-2013, 11:33 AM
  3. Replies: 4
    Last Post: 07-27-2013, 01:34 PM
  4. VBA code to delete cell ranges
    By rich_cirillo in forum Excel Help
    Replies: 3
    Last Post: 07-08-2013, 09:18 AM
  5. Import html source of url list in each cell
    By Sergio Alfaro Lloret in forum Excel Help
    Replies: 8
    Last Post: 07-31-2012, 03:03 AM

Posting Permissions

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