Views

...

Important:

Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog podem ser tratados como consultoria freelance.

E-mails

Deixe seu e-mail para receber atualizações...

eBook Promo

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

Tags: Bernardes, MS, Microsoft, Office, Excel, deletar, apagar, excluir, line, row, column, linhas, colunas, range, n-th

André Luiz Bernardes
A&A® - Work smart, not hard in any place.
Skype: inanyplace 


eBooks VBA na AMAZOM.com.br

LinkWithinBrazilVBAExcelSpecialist

Related Posts Plugin for WordPress, Blogger...

Vitrine