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 Emersondaguia
#46809
Boa tarde amigos, sou novo no forum , estou tendo dificuldade com esse codigo no excel
para alterar o cadastro na planilha, so consigo alterar a primeira linda da planilha que e a linha 6 se eu tirar o exit sub consigo cadastrar mas porem tenho que ficar apertando ok ate o loop encontrar a linha que quero alerar ...
Public Sub alterar()
linha = 6
Do Until shtdados.Cells(linha, "A") = ""
If shtdados.Cells(linha, "A") = shtcadastro.Range("cad_0") Then
For a = 1 To 11
shtdados.Cells(linha, "A").Offset(0, a) = shtcadastro.Range("cad_" & a).Value
Next
End If
MsgBox "Dados alterados com Sucesso", vbInformation, "Alterar"
Exit Sub
linha = linha + 1
Loop
End Sub
Por eduardogrigull
Posts
#46811
Só precisava por a msgbox e o exit sub dentro do "IF"... assim:
Código: Selecionar todos
Public Sub alterar()
linha = 6

Do Until shtdados.Cells(linha, "A") = ""
If shtdados.Cells(linha, "A") = shtcadastro.Range("cad_0") Then
For a = 1 To 11
shtdados.Cells(linha, "A").Offset(0, a) = shtcadastro.Range("cad_" & a).Value
Next
MsgBox "Dados alterados com Sucesso", vbInformation, "Alterar"
Exit Sub
End If
linha = linha + 1
Loop

End Sub
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