Results 1 to 9 of 9

Coloring multiple rows

Threaded View

  1. #1
    Registered User
    Join Date
    05-25-2010
    Location
    Copenhagen
    MS-Off Ver
    Excel 2003
    Posts
    2

    Coloring multiple rows

    Hello

    I have nearly the perfect macro for my job, but I need one little change. The thing I is that my macro should color the row within the search conditions is and the two rows below. At this moment it only colors the row with the search result.

    Heres my macro:

    Sub Farv_weekend()
    
        Dim LRow As Integer
        Dim LCell As String
        Dim LColorCells As String
        'Start at row 4
        LRow = 4
    
        'Update row colors for the first 150 rows
        While LRow < 150
            LCell = "A" & LRow
            'Color will changed in columns A to G
            LColorCells = "A" & LRow & ":" & "G" & LRow
    
            Select Case Left(Range(LCell).Value, 6)
    
                'Set row color to light blue
                Case "Lørdag"
                    Range(LColorCells).Interior.ColorIndex = 15
                    Range(LColorCells).Interior.Pattern = xlSolid
    
                'Set row color to light green
                Case "Søndag"
                    Rows(LRow & ":" & LRow).Select
                    Range(LColorCells).Interior.ColorIndex = 15
                    Range(LColorCells).Interior.Pattern = xlSolid
    
                'Default all other rows to no color
                Case Else
                    Rows(LRow & ":" & LRow).Select
                    Range(LColorCells).Interior.ColorIndex = xlNone
    
            End Select
    
            LRow = LRow + 1
        Wend
    
        Range("A1").Select
    
    End Sub
    Looking forward to get some help

    Anders
    Denmark
    Last edited by Anders.Hoejlund; 07-21-2010 at 07:37 AM.

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