Sou iniciante em VBA estou criando uma planilha para editar
produtos
criei o formulário e está funcionando, queria modificar o seguinte
Quando localizar mais de um produto com o parâmetro informado ele abrir outra tela, permitir selecionar o item, clicar em confirmar e depois carregar os dados desse produto na tela principal
segue abaixo código atual
Public Linha As Double
Public UltimaLinha As Double
Private Sub ComboBox1_Change()
End Sub
Private Sub CommandButton1_Click()
'On Error GoTo Erro
If TextBox1 = "" Then
MsgBox "Precisa fornecer criterio de pesquisa", vbCritical, "PESQUISA"
TextBox1.SetFocus
Exit Sub
End If
Dim Pesquisa As Integer
On Error Resume Next
Pesquisa = Cells.Find(What:=TextBox1, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
texto = Planilha2.Range("C3".AutoComplete(Pesquisa)
If Pesquisa <> "0" Then
Linha = ActiveCell.Row
If Linha < UltimaLinha Then
Call limpar
MsgBox "Fim Da Pesquisa", vbInformation, "Pesquisa"
Exit Sub
End If
UltimaLinha = Linha
Call Carregar
Else
MsgBox "produto não encontrador", vbInformation, "PESQUISA"
Call limpar
End If
Exit Sub
Erro:
MsgBox "Erro!", vbCritical, "ERRO"
End Sub
Sub Carregar()
On Error GoTo Erro
TextBox2 = Planilha2.Cells(Linha, 1).Value
TextBox3 = Planilha2.Cells(Linha, 2).Value
TextBox4 = Planilha2.Cells(Linha, 3).Value
TextBox5 = Planilha2.Cells(Linha, 4).Value
CommandButton2.Enabled = True
Exit Sub
Erro:
MsgBox "Erro!", vbCritical, "ERRO"
End Sub
Sub limpar()
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
Linha = Empty
UltimaLinha = Empty
CommandButton2.Enabled = False
Planilha2.Range("A1".Select
End Sub
Private Sub CommandButton2_Click()
On Error GoTo Erro
If TextBox5 = "" Then
MsgBox "CAMPO QUANTIDADE VAZIO", vbInformation, "EDITAR"
Exit Sub
End If
Dim quantidade As Double
On Error Resume Next
quantidade = TextBox4
Planilha2.Cells(Linha, 1).Value = TextBox2
Planilha2.Cells(Linha, 2).Value = TextBox3
Planilha2.Cells(Linha, 3).Value = TextBox4
Planilha2.Cells(Linha, 4).Value = TextBox5
Call limpar
TextBox1 = ""
TextBox1.SetFocus
MsgBox "Produto Alterado", vbinfomation, "ERRO"
Exit Sub
Erro:
MsgBox "Erro!", vbInformation, "ERRO"
End Sub
Private Sub Label1_Click()
End Sub
Private Sub Label4_Click()
End Sub
Private Sub TextBox1_Change()
Call limpar
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
Linha = Empty
UltimaLinha = Empty
TextBox1 = SetFocus
CommandButton2.Enabled = False
Planilha2.Range("A1".Select
End Sub
segue em anexo imagem da tela atual