Segue codigo q estou utilizando:
'Copiar valor
Range("Z1").Select
Range("Z1").AutoFilter Field:=32, Criteria1:=RGB(192 _
, 192, 192), Operator:=xlFilterCellColor
TrabalharVazias2 ()
Range("Y1").Select
Range("Z1").AutoFilter Field:=31, Criteria1:=RGB(192 _
, 192, 192), Operator:=xlFilterCellColor
Range("Y2").Resize(Range("Y" & Rows.Count).End(xlUp).Row + 1).EntireRow.Select
Selection.Interior.Color = RGB(192, 192, 192)
Range("Y1").Select
ActiveSheet.ShowAllData
Columns("AG:AG").Select
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("Z2").Select
Selection.ClearContents
-------
Sub TrabalharVazias2 ()
Dim lig As Long
lig = 1 'primeira linha a verificar
'Contar até achar linha vazia
Do While Not IsEmpty(Range("Z" & lig))
lig = lig + 1
Loop
If Range("Z" & lig) = "" Then
Range("Z" & lig).Select
ActiveCell.FormulaR1C1 = "=INDIRECT(""D""&ROW()-1,1)-SUM(R[-1]C)"
ActiveCell.Select
Selection.AutoFill Destination= ActiveCell.Range
Range("Z" & lig).Copy
Range("Z" & lig).Resize(Range("Y" & Rows.Count).End(xlUp).Row + 1).Select
ActiveSheet.Paste
Postado : 30/07/2018 5:57 am