+ Reply to Thread
Results 1 to 2 of 2

Conditional formatting multiple columns

  1. #1
    Registered User
    Join Date
    06-06-2008
    Posts
    5

    Conditional formatting multiple columns

    I posted this in general but, as someone pointed out, this would be a better place.

    I apologize for double posting.

    So I searched the net and the forum and I obtained the code and how-to so that I could use more than 3 conditional formats but I need some help expanding the code.

    (I am trying to also figure out how to change my column labels from numbers back to letters.)

    Instead of 1 column, I need to do it in three columns.

    Here is the original code (thank you very much!)

    Do I just repeat this for each column?

    ____________________________________________________________
    Option Explicit


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim WatchRange As Range
    Dim CellVal As Integer
    If Target.Cells.Count > 1 Then Exit Sub
    If Not IsNumeric(Target) Then Exit Sub
    CellVal = Target.Value
    Set WatchRange = Range("D7:D500")

    If Not Intersect(Target, WatchRange) Is Nothing Then
    Select Case CellVal
    Case 0.1 To 32.47
    Target.Interior.ColorIndex = 5
    Case 32.48 To 58.63
    Target.Interior.ColorIndex = 10
    Case 58.64 To 70.19
    Target.Interior.ColorIndex = 6
    Case 70.2 To 77.71
    Target.Interior.ColorIndex = 46
    Case 77.72 To 100
    Target.Interior.ColorIndex = 45
    Case Else
    Target.Interior.ColorIndex = xlNone
    End Select
    End If
    End Sub

  2. #2
    Registered User
    Join Date
    06-06-2008
    Posts
    5
    would this be the way to do it?

    Option Explicit


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim WatchRange As Range
    Dim CellVal As Integer
    If Target.Cells.Count > 1 Then Exit Sub
    If Not IsNumeric(Target) Then Exit Sub
    CellVal = Target.Value
    Set WatchRange = Range("R7C4:R500C4")

    If Not Intersect(Target, WatchRange) Is Nothing Then
    Select Case CellVal
    Case 0.1 To 32.47
    Target.Interior.ColorIndex = 5
    Case 32.48 To 58.63
    Target.Interior.ColorIndex = 10
    Case 58.64 To 70.19
    Target.Interior.ColorIndex = 6
    Case 70.2 To 77.71
    Target.Interior.ColorIndex = 46
    Case 77.72 To 100
    Target.Interior.ColorIndex = 45
    Case Else
    Target.Interior.ColorIndex = xlNone
    End Select


    Dim WatchRange As Range
    Dim CellVal As Integer
    If Target.Cells.Count > 1 Then Exit Sub
    If Not IsNumeric(Target) Then Exit Sub
    CellVal = Target.Value
    Set WatchRange = Range("R7C5:R500C5")

    If Not Intersect(Target, WatchRange) Is Nothing Then
    Select Case CellVal
    Case 0.1 To 32.47
    Target.Interior.ColorIndex = 5
    Case 32.48 To 58.63
    Target.Interior.ColorIndex = 10
    Case 58.64 To 70.19
    Target.Interior.ColorIndex = 6
    Case 70.2 To 77.71
    Target.Interior.ColorIndex = 46
    Case 77.72 To 100
    Target.Interior.ColorIndex = 45
    Case Else
    Target.Interior.ColorIndex = xlNone
    End Select

    Dim WatchRange As Range
    Dim CellVal As Integer
    If Target.Cells.Count > 1 Then Exit Sub
    If Not IsNumeric(Target) Then Exit Sub
    CellVal = Target.Value
    Set WatchRange = Range("R7C6:R500C6")

    If Not Intersect(Target, WatchRange) Is Nothing Then
    Select Case CellVal
    Case 0.1 To 32.47
    Target.Interior.ColorIndex = 5
    Case 32.48 To 58.63
    Target.Interior.ColorIndex = 10
    Case 58.64 To 70.19
    Target.Interior.ColorIndex = 6
    Case 70.2 To 77.71
    Target.Interior.ColorIndex = 46
    Case 77.72 To 100
    Target.Interior.ColorIndex = 45
    Case Else
    Target.Interior.ColorIndex = xlNone
    End Select
    End If
    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