About Me
Com tecnologia do Blogger.
Seguidores
Estatisticas
2006-01-14
Se tivermos um determinado Range de dados como no exemplo que se segue:

e quisermos colorir as linhas totalmente em branco desse Range:

Podemos utilizar um pouco de VBA.
O Código:
Private Sub CommandButton2_Click()
Dim RowNdx As Long
Dim LastRow As Long
Dim x
Dim y
LastRow = ActiveSheet.UsedRange.Rows.Count
For RowNdx = LastRow To 1 Step -1
On Error Resume Next
x = Cells(RowNdx, "A").Value = ""
y = Cells(RowNdx, "H").Value = ""
If x Then
If y Then
Cells(RowNdx, "A").Interior.ColorIndex = 48
Cells(RowNdx, "B").Interior.ColorIndex = 48
Cells(RowNdx, "C").Interior.ColorIndex = 48
Cells(RowNdx, "D").Interior.ColorIndex = 48
Cells(RowNdx, "E").Interior.ColorIndex = 48
Cells(RowNdx, "F").Interior.ColorIndex = 48
Cells(RowNdx, "G").Interior.ColorIndex = 48
Cells(RowNdx, "H").Interior.ColorIndex = 48
End If
End If
Next RowNdx
End Sub
e quisermos colorir as linhas totalmente em branco desse Range:
Podemos utilizar um pouco de VBA.
O Código:
Private Sub CommandButton2_Click()
Dim RowNdx As Long
Dim LastRow As Long
Dim x
Dim y
LastRow = ActiveSheet.UsedRange.Rows.Count
For RowNdx = LastRow To 1 Step -1
On Error Resume Next
x = Cells(RowNdx, "A").Value = ""
y = Cells(RowNdx, "H").Value = ""
If x Then
If y Then
Cells(RowNdx, "A").Interior.ColorIndex = 48
Cells(RowNdx, "B").Interior.ColorIndex = 48
Cells(RowNdx, "C").Interior.ColorIndex = 48
Cells(RowNdx, "D").Interior.ColorIndex = 48
Cells(RowNdx, "E").Interior.ColorIndex = 48
Cells(RowNdx, "F").Interior.ColorIndex = 48
Cells(RowNdx, "G").Interior.ColorIndex = 48
Cells(RowNdx, "H").Interior.ColorIndex = 48
End If
End If
Next RowNdx
End Sub