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 kleinowski
Posts
#43913
Olá!
Estou com um problema em um código. Na verdade eu usei este código em outra planilha e estou adaptando ele.
A questão é tenho uma planilha com alguns nomes e nas colunas ao lado tenho 5 opções.
Quando eu seleciono o nome ele carrega nos textbox as informações.
Ai é que está o problema, eu sei aonde está o problema do código mas não sei como resolver.
Segue o código.
Código: Selecionar todos
Dim W       As Worksheet
Dim i       As Long
Dim l       As Long

Set W = Sheets("Rodeio")
l = 3 'linha de inicio"
i = W.Range("D" & Rows.Count).End(xlUp).Row 'coluna
Do Until i > l

    If CDbl(Entidade.Text = (W.Cells(l, 16))) Then
    textbox1 = (W.Cells(l, 17))
        textbox2.Text = W.Cells(l, 18)
        textbox3.Text = W.Cells(l, 19)
        textbox4.Text = W.Cells(l, 20)
        textbox5.Text = W.Cells(l, 21)
                            
    End If
        i = i + 1
Loop

Ao meu ver o problema está em "l = 3 'linha de inicio" ele busca informação só na linha 3, porem tenho 30 nomes abaixo. Como posso resolver isso?
Por osvaldomp
#43922
Código: Selecionar todos
 Dim W As Worksheet, i As Long, l As Long
  Set W = Sheets("Rodeio")
  i = W.Range("D" & Rows.Count).End(xlUp).Row 'última linha com conteúdo na coluna D
  For l = 3 To i
   If CDbl(Entidade.Text) = W.Cells(l, 16) Then
    textbox1.Text = W.Cells(l, 17)
    textbox2.Text = W.Cells(l, 18)
    textbox3.Text = W.Cells(l, 19)
    textbox4.Text = W.Cells(l, 20)
    textbox5.Text = W.Cells(l, 21)
   End If
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