+ Reply to Thread
Results 1 to 2 of 2

Extending color fill to the left in VBA

Hybrid View

josephrowan Extending color fill to the... 08-28-2007, 03:27 PM
josephrowan I think I got it 08-28-2007, 04:29 PM
  1. #1
    Registered User
    Join Date
    09-15-2004
    Posts
    10

    Extending color fill to the left in VBA

    [SIZE="2"]I have this code that colors rows based on input. It works fine when in the A column and can stretch to the right. Now, I have used this same vba to highlight a middle column and would like to have the cells to the left and right get colored.

    I gave it my best shot, but kept missing. Any thoughts?

    thanks

    Private Sub worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("C1:C500")) Is Nothing Then _
    Invoices Intersect(Target, Range("C1:C500"))
    End Sub
    
    Sub Invoices(ByVal rng As Range)
    Dim r As Range, myColor As Integer
    For Each r In rng
    myColor = xlNone
    Select Case r.Value
    Case "DEEPLY LAPSED" To "DEEPLY LAPSED ZZ"
    myColor = 35
    
    End Select
    r.Resize(, 5).Interior.ColorIndex = myColor
    Next
    End Sub

  2. #2
    Registered User
    Join Date
    09-15-2004
    Posts
    10

    I think I got it

    .....but it probably is hackish. Still, it works.

    in the end select, the change is
    
    End Select
    r.Resize.Offset(, -2).Interior.ColorIndex = myColor
    r.Resize.Offset(, -1).Interior.ColorIndex = myColor
    r.Resize(, 5).Interior.ColorIndex = myColor
    
    Next
    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