Macro Needed

ironsides

Well-known Member
Joined
Aug 12, 2002
Messages
575
Data starts line 7 col A thru DZ
Some lines are blank

Macro required to search all lines and
put color gray on all lines that contain no data
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
s/b a decent start

Code:
Sub GreyFillActiveSheetWhereRowHasNoData()
'http://www.mrexcel.com/forum/showthread.php?t=580572
    Dim C As Range
    Dim RowIdx As Long
    Application.ScreenUpdating = False
    TR = 7
    BR = Cells(Rows.Count, 1).End(xlUp).Row

    For RowIdx = BR To TR Step -1
        For Each C In Range("A" & RowIdx, "DZ" & RowIdx)
            boolColorRow = True
            C.Select: Debug.Print C.Value & "|"
            If Not IsEmpty(C) Then
                boolColorRow = False
                'ClearRowColor RowIdx 'Optional No Fill of Row
                Exit For
            End If
        Next C
        If boolColorRow Then
            ColorRow RowIdx
        End If
        Cells(RowIdx, 1).Select
    Next RowIdx
    Application.ScreenUpdating = True
End Sub
Function ColorRow(RowNum As Long)
    With Rows(RowNum).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.149998474074526
        .PatternTintAndShade = 0
    End With
End Function
Function ClearRowColor(RowNum As Long)
    With Rows(RowNum).Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Function
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top