Results 1 to 3 of 3

Thread: How to change cell color in excel based on text input

  1. #1
    Join Date
    Dec 2011
    Posts
    64

    How to change cell color in excel based on text input

    I want the cell format (meaning color of the cell) to change based upon the text entered. I have used up the conditional formatting. It only allows three formats, and I require more. I am inquiring if this can be made into a formula for a cell to have the color change upon certain text phrases? So if you have any information then please do the reply.

  2. #2
    Join Date
    Mar 2011
    Posts
    542

    Re: How to change cell color in excel based on text input

    Try this event code.

    Option Compare Text
    Private Sub Worksheet_Change(ByVal Target As Range)
    Set r = Range("A1:A20")
    If Intersect(Target, r) Is Nothing Then
    Exit Sub
    End If
    On Error GoTo Endit
    Application.EnableEvents = False
    vals = Array("Cat", "Dog", "Gopher", "Hyena", "Ibex", "Lynx", _
    "Ocelot", "Skunk", "Tiger", "Yak")
    nums = Array(8, 9, 6, 3, 7, 4, 20, 10, 23, 15)
    For Each rr In r
    icolor = 0
    For i = LBound(vals) To UBound(vals)
    If rr.Value = vals(i) Then
    icolor = nums(i)
    End If
    Next
    If icolor <> 0 Then
    rr.Interior.ColorIndex = icolor
    End If
    Next
    Endif:
    Application.EnableEvents = True
    End Sub
    Right-click on the sheet tab and "View Code". Copy/paste to that sheet module.

    Edit then Alt + q to return to the Excel window.

  3. #3
    Join Date
    May 2011
    Posts
    523

    Re: How to change cell color in excel based on text input

    Select A1:A4 and in Conditional Formatting use Formula Is (in Excel 2007: New Rule / based on formula), with =A1=$A$5 and set the formatting you want.

Similar Threads

  1. How to make a Cell input Mandatory in Excel
    By hanni ball in forum MS Office Support
    Replies: 4
    Last Post: 01-02-2012, 07:05 PM
  2. Based on Cell Criteria Delete Row in excel
    By AlpAnA$ in forum Windows Software
    Replies: 5
    Last Post: 09-07-2011, 08:50 PM
  3. How to change text color using 'IF" in Excel
    By Antrix in forum Windows Software
    Replies: 2
    Last Post: 26-06-2009, 07:02 PM
  4. Excel Added macro for cell color
    By Xylon in forum Software Development
    Replies: 3
    Last Post: 19-02-2009, 12:15 PM
  5. Excel 2000 - Change Default Cell Fill Color
    By Cris Han in forum MS Office Support
    Replies: 2
    Last Post: 20-02-2008, 09:29 PM

Tags for this Thread

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
  •  
Page generated in 1,713,525,481.95225 seconds with 17 queries