Preciso de uma macro que pesquise uma coluna inteira de datas de conclusão e exclua sua linha de dados correspondente se 90 dias se passaram desde a data de conclusão. Aqui está o que eu tenho até agora.
Dim RowDate
Dim CurrentDate
Dim Interval
Dim CurrentAddress
Dim ValueCellRange As Range
Dim ValueCell As Range
"Interval set to an appropriate number of days
Interval = 90
CurrentDate = Now()
"Identify starting row for sweep
Set ValueCellRange = Range("G2:G100")
"Set loop to execute until empty cell is reached
For Each ValueCell In ValueCellRange
If CurrentDate - ValueCell.Value >= Interval Then
ValueCell.EntireRow.ClearContents
End If
Next ValueCell
"Clear variable value for next initialization
Set ValueCell = Nothing
Respostas:
1 para resposta № 1Se você apenas quiser pular espaços em branco, adicione outra instrução if no seu loop
Editar loop adicionado pelas planilhas
Dim ws as Worksheet
For Each ws in Worksheets
Set ValueCellRange = ws.Range("G2:G100")
For Each ValueCell In ValueCellRange
If ValueCell.Value <> "" Then
If CurrentDate - ValueCell.Value >= Interval Then
ValueCell.EntireRow.ClearContents
End If
End If
Next ValueCell
Next ws