Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por engrocha
Posts
#46750
Boa tarde a todos!
Gostaria de um código que faça a localização de linhas usando como critério o "DIA" e faça a exclusão dessas linhas movimentando o restante para cima.

Segue anexo com o exemplo e a explicação mais detalhada do "problema".

Desde já agradeço,
Rocha.
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por Reinaldo
Avatar
#46753
uma possibilidade
Código: Selecionar todos
Function intLinExclporCriterio(ByVal lngLinInic As Long, ByVal lngLinFim As Long, ByVal lngColCriterio As Long, ByVal strCriterio As String) As Integer
Dim strLinExcluida As Long, lngI As Long
strLinExcluida = 0
With ActiveSheet
    lngI = lngLinInic
        While lngI < lngLinFim
            If CStr(.Cells(lngI, lngColCriterio).Value) = strCriterio Then
                .Rows(lngI).Delete
                strLinExcluida = strLinExcluida + 1
            Else
                lngI = lngI + 1
            End If
        Wend
End With
intLinExclporCriterio = strLinExcluida
End Function

Sub Modelo_de_Chamada()
'Sintaxe de chamada da função intLinExclporCriterio
' nome da função numero da linha inicial, numero da linha final, numero da coluna do criterio e criterio a ser considerado
'no exemplo abaixo --. A partir da linha 1 até linha 2000 excluir linhas cuja valor Celula da coluna B (2) seja 2
MsgBox intLinExclporCriterio(1, 2000, 2, 2) & " Linhas foram excluidas"
End Sub
Por osvaldomp
#46761
Na planilha você escreveu:
... a principal referência é a coluna "B", que são os dias. ~~~> coluna B é coluna 2
... se eu digitar na célula L3 ( você citou L3 mas na planilha colocou um valor em L2 :?: ) o valor "5" e clickar no botão "Excluir", o código irá procurar na coluna 3 ... ~~~> aqui você colocou coluna 3 :?:

Considerei a célula L3 e a coluna B como sendo as referências.
Código: Selecionar todos
Sub ExcluiLinhas()
 ActiveSheet.AutoFilterMode = False
 Range("A2:D2").AutoFilter 2, [L3]
 If ActiveSheet.AutoFilter.Range.Columns(2).SpecialCells(xlCellTypeVisible).Count > 1 Then
  Range("B3:B" & Cells(Rows.Count, 2).End(3).Row).SpecialCells(xlCellTypeVisible).EntireRow.Delete
 End If
 ActiveSheet.AutoFilterMode = False
End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord