| Blog Office VBA | Blog Excel | Blog Access |
Sim pessoal. sempre perguntam como deletar linhas em branco da planilha, assim que esta for aberta. Segue um código, simples, honesto, rápido e limpinho:
Private Sub Worksheet_Change (ByVal Target As Range)
'Deleta todas as linhas que estiverem em branco que existirem.'Previne loops infinitos Let Application.EnableEvents = False'Caso haja mais de uma célula selecionada.
If Target.Cells.Count > 1 ThenGoTo SelectionCodeIf WorksheetFunction.CountA(Target.EntireRow) = 0 ThenTarget.EntireRow.DeleteEnd If
Let Application.EnableEvents = TrueExit Sub
SelectionCode:If WorksheetFunction.CountA(Selection.EntireRow) = 0 ThenSelection.EntireRow.DeleteEnd If
Let Application.EnableEvents = True
End Sub
Tags: VBA, Excel, deletar, apagar, excluir, rows, blank, lines, linha, range, removing, EntireRow, automatically, delete

Nenhum comentário:
Postar um comentário