+ Reply to Thread
Results 1 to 4 of 4

Fill Color row to specific column

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Fill Color row to specific column

    Hi, i have this code below but it fills the entire row with gray color. I only want it to fill from columns A to F. Thanks

    Application.ScreenUpdating = False
    Dim lngLstCol As Long, lngLstRow As Long
    
    lngLstRow = ActiveSheet.UsedRange.Rows.Count
    lngLstCol = ActiveSheet.UsedRange.Columns.Count
    
    For Each RngCell In Range("A19:A" & lngLstRow)
        If RngCell.Value > "" Then
            r = RngCell.row
            C = RngCell.Column
            Range(Cells(r, C), Cells(r, lngLstCol)).Select
                With Selection.Borders
                    .LineStyle = xlContinuous
                    .Weight = xlThin
                    .ColorIndex = xlAutomatic
                End With
                If RngCell.row Mod 2 = 1 Then RngCell.EntireRow.Interior.ColorIndex = 15
        End If
    Next
    
    Application.ScreenUpdating = True

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Fill Color row to specific column

    
    Application.ScreenUpdating = False
    
    For Each RngCell In Range("A19:F" & ActiveSheet.UsedRange.Rows.Count)
        If RngCell.Value > "" Then
    
                With RngCell.Borders
                    .LineStyle = xlContinuous
                    .Weight = xlThin
                    .ColorIndex = xlAutomatic
                End With
    
                If RngCell.row Mod 2 = 1 Then RngCell.EntireRow.Interior.ColorIndex = 15
        End If
    Next
    
    Application.ScreenUpdating = True
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Re: Fill Color row to specific column

    Quote Originally Posted by mehmetcik View Post
    
    Application.ScreenUpdating = False
    
    For Each RngCell In Range("A19:F" & ActiveSheet.UsedRange.Rows.Count)
        If RngCell.Value > "" Then
    
                With RngCell.Borders
                    .LineStyle = xlContinuous
                    .Weight = xlThin
                    .ColorIndex = xlAutomatic
                End With
    
                If RngCell.row Mod 2 = 1 Then RngCell.EntireRow.Interior.ColorIndex = 15
        End If
    Next
    
    Application.ScreenUpdating = True

    Thanks mehmetcik but this still colors the entire row

  4. #4
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Re: Fill Color row to specific column

    Actually i got it...thanks

    Application.ScreenUpdating = False

    For Each RngCell In Range("A19:F" & ActiveSheet.UsedRange.Rows.Count)
        If RngCell.Value > "" Then
    
                With RngCell.Borders
                    .LineStyle = xlContinuous
                    .Weight = xlThin
                    .ColorIndex = xlAutomatic
                End With
    
                If RngCell.Row Mod 2 = 1 Then RngCell.Interior.ColorIndex = 15
        End If
    Next
    
    Application.ScreenUpdating = True

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy only cells with a specific fill color
    By juanp21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2014, 09:54 AM
  2. Trying to sum cells with a specific fill color
    By SargeUSMC in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-18-2013, 09:34 PM
  3. how to find a color in a row where the color is blue , if true fill with a specific text
    By jayakumar.chandran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2012, 03:38 AM
  4. Replies: 3
    Last Post: 07-08-2010, 06:48 PM
  5. fill color specific cells
    By tomvh444 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-23-2009, 04:29 PM

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