Quero saber como faço para que os valores inseridos nos txt1, txt2 e txt3 sejam gravados nas celulas repetindo: veja código.
Tentei fazer algumas mudanças, mas não dá certo!
Private Sub CommandButton1_Click()
Dim lastRow As Long
Dim rg As Range
' Verifica qual a ultima linha preenchida (Plan1 - VBAProject)
lastRow = Plan1.Cells(Rows.Count, 1).End(xlUp).Row
'Guarda a area a procurar colunaA se dados repetidos txt1
Set rg = Plan1.Range("A2:A" & lastRow)
'Caso não encontre nenhum nome igual cadastra
' If rg.Find(TextBox3.Text) Is Nothing Then
If MsgBox("Confirma entrada de dados de: " & Me.TextBox3 & " ?", vbYesNo + vbQuestion, "Cadastro") = vbNo Then
Exit Sub
End If
Plan2.Cells(lastRow + 1, 1) = TextBox3.Text
Plan2.Cells(lastRow + 1, 2) = TextBox4.Text
Plan2.Cells(lastRow + 1, 3) = TextBox5.Text
'aqui seria só seguir a lógica com sua realidade
' Else
' MsgBox "Código já existente!", vbCritical
'Exit Sub
' End If
MsgBox "Entrada de dados: " & Me.TextBox3 & " realizada com sucesso !!!", 64, "Cadastro"
TextBox3.Value = Clear
TextBox4.Value = Clear
TextBox5.Value = Clear
End Sub
Pergunta
vbaLimoeiro
Quero saber como faço para que os valores inseridos nos txt1, txt2 e txt3 sejam gravados nas celulas repetindo: veja código.
Tentei fazer algumas mudanças, mas não dá certo!
Private Sub CommandButton1_Click() Dim lastRow As Long Dim rg As Range ' Verifica qual a ultima linha preenchida (Plan1 - VBAProject) lastRow = Plan1.Cells(Rows.Count, 1).End(xlUp).Row 'Guarda a area a procurar colunaA se dados repetidos txt1 Set rg = Plan1.Range("A2:A" & lastRow) 'Caso não encontre nenhum nome igual cadastra ' If rg.Find(TextBox3.Text) Is Nothing Then If MsgBox("Confirma entrada de dados de: " & Me.TextBox3 & " ?", vbYesNo + vbQuestion, "Cadastro") = vbNo Then Exit Sub End If Plan2.Cells(lastRow + 1, 1) = TextBox3.Text Plan2.Cells(lastRow + 1, 2) = TextBox4.Text Plan2.Cells(lastRow + 1, 3) = TextBox5.Text 'aqui seria só seguir a lógica com sua realidade ' Else ' MsgBox "Código já existente!", vbCritical 'Exit Sub ' End If MsgBox "Entrada de dados: " & Me.TextBox3 & " realizada com sucesso !!!", 64, "Cadastro" TextBox3.Value = Clear TextBox4.Value = Clear TextBox5.Value = Clear End SubEditado por kuroiAdicionar tag CODE
Link para o comentário
Compartilhar em outros sites
4 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.