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 Super385011
Posts
#34732
Boa noite

Estou usando este código para fazer alteração na planilha via formulário, mas agora ele em vez de modificar a linha selecionada ele muda a linha anterior.


Private Sub CmdAlterar_Click()

Dim Lin As Long
Dim i As Long

Lin = Sheets("Plan1").Cells(Cells.Rows.Count, 1).End(xlUp).Row
If Lin < 2 Then ling = 2

Application.ScreenUpdating = False
Sheets("Plan1").Activate

For i = 2 To Lin
If Range("A" & i).Value = CDate(TxtData.Text) Then
Cells(i, 1).Value = CDate(TxtData.Text)
Cells(i, 2).Value = Format(TxtValor.Text, "R$ 0.00#,##")
Cells(i, 3).Value = TxtDescrição.Text
Exit For
End If
Next

TxtData.Text = ""
TxtValor.Text = ""
TxtDescrição.Text = ""
Sheets("Menu").Activate
Application.ScreenUpdating = True

End Sub
Por osvaldomp
#34735
Super385011 escreveu:...em vez de modificar a linha selecionada ...
No seu código não há referência a "linha selecionada" :?:
Não sei se esta é a causa do seu problema:
If Lin < 2 Then ling = 2 ~~~> me parece que deveria ser If Lin < 2 Then Lin = 2
Por osvaldomp
#34745
sugestão - disponibilize uma amostra do seu arquivo Excel e explique com exatidão na própria planilha o que você deseja fazer e explique o que você quer dizer com "em vez de modificar a linha selecionada ele muda a linha anterior"
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