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 kleinowski
Posts
#61751
Olá tenho o seguinte código

Private Sub curso_AfterUpdate()

Dim W As Worksheet
Dim i As Integer
Dim l As Integer

Set W = Sheets("Cursos")
i = 2
l = W.Range("A" & Rows.Count).End(xlUp).Row

Do Until i > l
If CDbl(curso.Value) = (W.Cells(i, 1)) Then

sigla.Value = W.Cells(i, 2)

curso.SetFocus
Exit Sub
End If
i = i + 1
Loop

End Sub

basicamente ele compara o texto do combobox com o texto de uma célula.
Caso o texto seja igual o textbox (Sigla) deveria pegar o valor da celula (W.Cells(i, 2))

Porem quando executo isso da erro, diz Tipos incompatíveis, caso eu troque as variáveis Integer por String, o código executa porem não retorna nenhum valor.


OBS: Quando da erro o seguinte trecho fica destacado
If CDbl(curso.Value) = (W.Cells(i, 1)) Then
Se coloco o mouse em cima de curso.value e W.Cells aparece o texto correto.


Alguém consegue me dar uma ajudar para resolver 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