Views

Histats

Vitrine

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.




✔ VBA Brazil®

✔ VBA Brazil®
brazilsalesforceeffectiveness@gmail.com
Related Posts Plugin for WordPress, Blogger...
diHITT - Notícias