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.
Por avgsantos
Posts
#26074
Boa noite, Equipe do Forum

Estou utilizando o código abaixo para gerar contador automático dentro do userform "MultiPage1" porém ao cadastrar uma informação o contador está gerando numero repetido, não esta gerando na sequencia.

Private Sub MultiPage1_Layout(ByVal Index As Long)

'GERADOR DE CONTADOR

Dim linha As Long
Dim contador As Long
linha = 3
contador = 0
While Cells(linha, 1) <> ""
If Cells(linha, 1) > contador Then
contador = Cells(linha, 1)
End If
linha = linha + 1
Wend
contador = contador + 1
txt_id = contador


End Sub
Por avgsantos
Posts
#26106
Boa tarde.

Solução resolvida por Wagner.

Dim UltimaLinha As Long

UltimaLinha = Sheets("box1").Cells(Cells.Rows.Count, 1).End(xlUp).Row
If UltimaLinha < 3 Then
UltimaLinha = 3
txt_id.Caption = "1"
Else
txt_id.Caption = CInt(Range("A" & UltimaLinha).Value) + 1
End If

Grato
avgsantos
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