+ Reply to Thread
Results 1 to 7 of 7

Adding More Conditional Formating

  1. #1
    Registered User
    Join Date
    05-23-2005
    Posts
    13

    Question Adding More Conditional Formating

    Hello to all,

    I realized that Excel has a limit of 3 conditional formats. I read some post on this can be coded into the sheet but they only refered to numbers and not text. Does any know how I can code this into the my sheet? Any help would be appreciated, Thank you


    For cell range B7:B26

    If text contains "POI" Color background to "Rose"

    If text contains "KFI" Color background to "Tan"

    If text contains "EPT" Color background to 'Light yellow"

    If text contains "POC" Color background to 'Light green"

    If text contains "TPN" Color background to "Pale blue"

    If text contains "CII" Color background to 'Lavender"

    If text contains "OS" Colot background to "Gray-25%"

    If text contains "SP" Color background to 'Light orange"

  2. #2
    pm
    Guest

    Re: Adding More Conditional Formating

    november678x wrote:

    > Hello to all,
    >
    > I realized that Excel has a limit of 3 conditional formats. I read some
    > post on this can be coded into the sheet but they only refered to
    > numbers and not text. Does any know how I can code this into the my
    > sheet? Any help would be appreciated, Thank you
    >
    > For cell range B7:B26
    >
    > If text contains "POI" Color background to "Rose"
    >
    > If text contains "KFI" Color background to "Tan"
    >
    > If text contains "EPT" Color background to 'Light yellow"


    Paste this code to sheets code

    Private Sub Worksheet_Calculate()
    Dim rng As Range
    Application.ScreenUpdating = False

    For Each rng In Range("B7:B26")

    If rng.Value = "POI" Then
    rng.Interior.ColorIndex = 2
    ElseIf rng.Value = "KFI" Then
    rng.Font.ColorIndex = 3
    ElseIf rng.Value = "EPT" Then
    rng.Font.ColorIndex = 1
    'and so on...
    End If

    Next rng

    Application.ScreenUpdating = True
    End Sub

    rgs

  3. #3
    Registered User
    Join Date
    05-23-2005
    Posts
    13

    Question

    Thanks for the reply. I pasted this into the sheet code but the background color wont change when I enter the codes. Does the version of excel matter? Or is there another variation of this I can try?

    Thank you

  4. #4
    pm
    Guest

    Re: Adding More Conditional Formating

    november678x wrote:

    > Thanks for the reply. I pasted this into the sheet code but the
    > background color wont change when I enter the codes. Does the version
    > of excel matter? Or is there another variation of this I can try?


    i wrote:

    If rng.Value = "POI" Then
    rng.Interior.ColorIndex = 2
    ElseIf rng.Value = "KFI" Then
    rng.Font.ColorIndex = 3

    but of course shoul be Interior.ColorIndex (not Font)



  5. #5
    Registered User
    Join Date
    05-23-2005
    Posts
    13

    Question

    It still does not change color when I input the codes. Here is what I have in my sheet code, did I miss something?

    Thank you



    Private Sub Worksheet_Calculate()
    Dim rng As Range
    Application.ScreenUpdating = False

    For Each rng In Range("B7:B26")

    If rng.Value = "POI" Then
    rng.Interior.ColorIndex = 2

    ElseIf rng.Value = "KFI" Then
    rng.Interior.ColorIndex = 3

    ElseIf rng.Value = "EPT" Then
    rng.Interior.ColorIndex = 1

    End If

    Next rng

    Application.ScreenUpdating = True
    End Sub

  6. #6
    Registered User
    Join Date
    05-23-2005
    Posts
    13

    Question

    It still does not change color when I input the codes. Here is what I have in my sheet code, did I miss something?

    Thank you



    Private Sub Worksheet_Calculate()
    Dim rng As Range
    Application.ScreenUpdating = False

    For Each rng In Range("B7:B26")

    If rng.Value = "POI" Then
    rng.Interior.ColorIndex = 2

    ElseIf rng.Value = "KFI" Then
    rng.Interior.ColorIndex = 3

    ElseIf rng.Value = "EPT" Then
    rng.Interior.ColorIndex = 1

    End If

    Next rng

    Application.ScreenUpdating = True
    End Sub

  7. #7
    Registered User
    Join Date
    05-23-2005
    Posts
    13

    Question

    It still does not change color when I input the codes. Here is what I have in my sheet code, did I miss a step?

    Thank you



    Private Sub Worksheet_Calculate()
    Dim rng As Range
    Application.ScreenUpdating = False

    For Each rng In Range("B7:B26")

    If rng.Value = "POI" Then
    rng.Interior.ColorIndex = 2

    ElseIf rng.Value = "KFI" Then
    rng.Interior.ColorIndex = 3

    ElseIf rng.Value = "EPT" Then
    rng.Interior.ColorIndex = 1

    End If

    Next rng

    Application.ScreenUpdating = True
    End Sub

+ 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