Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49888

macro for select empty cells and coloring them

$
0
0
hi again atm im using this code
Code:

Private Function Provera() As Boolean
    Dim S1 As String, S2 As String
    Dim lRow As Long, i As Long
    Dim ws As Worksheet

    Set ws = ActiveWorkbook.Sheets("pppdp")

    With ws
        If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
            lRow = .Range("A:R").Find(What:="*", _
                          After:=.Range("A19"), _
                          Lookat:=xlPart, _
                          LookIn:=xlFormulas, _
                          SearchOrder:=xlByRows, _
                          SearchDirection:=xlPrevious, _
                          MatchCase:=False).Row
        Else
            lRow = 1
        End If

        Provera = Application.WorksheetFunction.CountA(.Range("A19:R" & lRow)) _
            = .Range("A19:R" & lRow).Cells.Count
    End With
    With Sheets("pppdp")
    ActiveSheet.Unprotect Password:="markop"
    .Range("A19:R" & .Range("A" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
    End With
End Function
Sub color()
ActiveSheet.Unprotect Password:="markop"
With Sheets("pppdp")
  .Range("A19:R" & .Range("A" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
  If Not Provera Then
    .Range("A19:R" & .Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 3
  End If
End With
ActiveSheet.Protect Password:="markop"
End Sub

but i have few more cells to check and color them in red like one in code... the cells i need to check is c4:c8, i try to do something but i colored a1:r18 any one have suggestion?

Viewing all articles
Browse latest Browse all 49888

Trending Articles