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 rafarangel1512
Posts
#55760
Sempre que tento clicar no "Requisitar peças" aparece erro de overflow e sei que é neste excerto de código:

Private Sub UserForm_Initialize()
Dim num_itens As Integer, Linha As Integer
num_itens = Worksheets("Menu").Range("A" & Rows.Count).End(xlUp).Row - 1
For Linha = 1 To num_itens
Tipo.AddItem Worksheets("Menu").Range("A2").Cells(Linha, 1)
Next Linha
End Sub

Alguém me poderia ajudar a solucionar?
Imagem
Imagem
Você não está autorizado a ver ou baixar esse anexo.
Por babdallas
#55761
O limite superior positivo da variável de tipo Integer é 32.767. Por isso, troque para Long, cujo limite é bem superior. Veja os limites aqui:

https://docs.microsoft.com/en-us/office ... pe-summary

Logo, troque esta linha
Código: Selecionar todos
Dim num_itens As Integer, Linha As Integer
Por
Código: Selecionar todos
Dim num_itens As Long, Linha As Long
Por babdallas
#55763
Tente isso
Código: Selecionar todos

Private Sub UserForm_Initialize()
      Dim num_itens As Long, Linha As Long

      num_itens = Worksheets("Menu").Range("A" & Rows.Count).End(xlUp).Row - 1
      
      For Linha = 1 To num itens
            VBA.DoEvents
            Tipo.AddItem Worksheets("Menu").Range("A2").Cells(Linha, 1)
      Next Linha
End Sub
Por babdallas
#55765
A célula A1048575 tinha algum caractere lá. Deletei tudo abaixo da última linha preenchida e acabou o problema.
Você não está autorizado a ver ou baixar esse anexo.
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