Closed Thread
Results 1 to 2 of 2

Conditional Formatting

Hybrid View

jhelliar Conditional Formatting 09-21-2007, 02:54 PM
VBA Noob Closed. Duplicate post.... 09-21-2007, 02:56 PM
  1. #1
    Forum Contributor
    Join Date
    09-21-2007
    Posts
    196

    Conditional Formatting

    I Would like to use more than 3 conditional formats but the visual basic code I found on the net only worked if I typed the number in and not if it was the result of a formula. Is there any way of getting it to work with formulae? I Have included the code below:

    'START OF CODE
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim WatchRange As Range
    Dim CellVal As Integer
    If Target.Cells.Count > 1 Then Exit Sub
    If Target = "" Or Not IsNumeric(Target) Then Exit Sub
    CellVal = Target
    Set WatchRange = Range("A1:A10")
    
    If Not Intersect(Target, WatchRange) Is Nothing Then
    Select Case CellVal
    Case 0 To 10
    Target.Interior.ColorIndex = 5
    Case 10 To 20
    Target.Interior.ColorIndex = 10
    Case 21 To 30
    Target.Interior.ColorIndex = 6
    Case 31 To 40
    Target.Interior.ColorIndex = 46
    Case 41 To 50
    Target.Interior.ColorIndex = 45
    End Select
    End If
    End Sub
    'END OF CODE

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Closed.

    Duplicate post. Please read forum rules below

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

Closed 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