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
  • Avatar do usuário
  • Avatar do usuário
Avatar do usuário
Por luizpaps
Posts Avatar
#63193
tenho algumas colunas com mais de 5000 linhas ex.:
1
2
3
5
1
2
3
7
9
1
preciso de uma macro para saber qual o maior intervalo que ficou sem aparecer o número 1
Editado pela última vez por luizpaps em 29 Mar 2021 às 08:53, em um total de 1 vez.
Avatar do usuário
Por Foxtri
Posts Avatar
#63286
Bom dia.
Considerando seus dados na coluna "A" (Pode ser outra, neste caso devera mudar a macro)), a partir de A2.....An.

Sub MaiorIntervalo()
Dim c As Range, mi As Long, mf As Long, k As Long
Application.ScreenUpdating = False
ActiveSheet.AutoFilterMode = False
If [a1] = "" Then [a1] = "X"
ActiveSheet.[a1].AutoFilter 1, 1
mi = 1
For Each c In Range("a2:a" & Cells(Rows.Count, 3).End(3).Row).SpecialCells(xlVisible)
If c.Row - mi > k Then k = c.Row - mi - 1
mi = c.Row
Next c
ActiveSheet.AutoFilterMode = False
MsgBox "MAIOR INTERVALO = " & k
End Sub

Veja se funciona.
Até
Foxtri
luizpaps agradeceu por isso
Avatar do usuário
Por JCabral
Avatar
#63298
É só alterar:
Código: Selecionar todos
For Each c In Range("a2:a" & Cells(Rows.Count, 3).End(3).Row).SpecialCells(xlVisible)
para
Código: Selecionar todos
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(3).Row).SpecialCells(xlVisible)
pequeno engano do @Foxtri, em vez da coluna "C" deve ser a coluna "A"
luizpaps agradeceu por isso
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