Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

.: Vitrine

Carregando artigos...

Views

Mostrando postagens com marcador automatically. Mostrar todas as postagens
Mostrando postagens com marcador automatically. Mostrar todas as postagens

Excel Tips - Excluindo linhas em branco ao abrir a Planilha - Removing Blank Rows Automatically


Olá pessoal!

Alguns perguntaram como fazer para deletar as linhas que estão em branco na planilha, logo que a 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 Then
GoTo SelectionCode  
If WorksheetFunction.CountA(Target.EntireRow) = 0 Then 
Target.EntireRow.Delete 
End If  
Let Application.EnableEvents = True  
Exit Sub
SelectionCode: 
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then 
Selection.EntireRow.Delete 
End If  
Let Application.EnableEvents = True
End Sub


Tags: VBA, Excel, deletar, apagar, excluir, row, lines, linha, range, rows, blank, removing, EntireRow, automatically, delete

VBA Excel - Excluir linhas em branco logo ao abrir a Planilha - Removing Blank Rows Automatically



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 Then
GoTo SelectionCode  
If WorksheetFunction.CountA(Target.EntireRow) = 0 Then 
Target.EntireRow.Delete 
End If  


Let Application.EnableEvents = True  
Exit Sub  

SelectionCode: 
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then 
Selection.EntireRow.Delete 
End If  


Let Application.EnableEvents = True
End Sub

Tags: VBA, Excel, deletar, apagar, excluir, rows, blank, lines, linha, range, removing, EntireRow, automatically, delete





VBA Excel - Deletando Colunas ou Linhas no Range - Delete Columns or Lines in the range



Caros,
Continuando na linha: "Revisitando As primeiras funções que desenvolvi".




DICA: Todas as funções que criarmos que tenham interação física direta nas planilhas que estivermos utilizando, terão uma performance muito melhor se colocarmos o comando Application.ScreenUpdating = False, antes do início do respectivo processamento.



Como deletar as linhascolunas num range informado?





Sub DelEveryNthR (DeleteRange As Range, N As Integer)



    Dim rCount As Long, r As Long







    Application.ScreenUpdating = False




    If DeleteRange Is Nothing Then Exit Sub



    If DeleteRange.Areas.Count > 1 Then Exit Sub



    If N < 2 Then Exit Sub







    With DeleteRange



        Let rCount = .Rows.Count







        For r = N To rCount Step N - 1



            .Rows(r).EntireRow.Delete



        Next r



    End With



End Sub







Sub DeleteEveryNthC (DeleteRange As Range, N As Integer)



    Dim cCount As Long, c As Long




    Application.ScreenUpdating = False




    If DeleteRange Is Nothing Then Exit Sub



    If DeleteRange.Areas.Count > 1 Then Exit Sub



    If N < 2 Then Exit Sub







    With DeleteRange



        Let cCount = .Columns.Count







        For c = N To cCount Step N - 1



            .Columns(c).EntireColumn.Delete



        Next c



    End With



End Sub




TagsBernardes, MS, Microsoft, Office, Excel, deletar, apagar, excluir, row, lines, linha, range, rows, blank, removing, EntireRow, automatically, delete, column, coluna



André Luiz Bernardes
A&A® - Work smart, not hard.




diHITT - Notícias