MauricioMello
09-10-2015 20:57:37
PESSOAL SOU LEIGO NO ASSUNTO E NOVO POR AQUI!
GOSTARIA DA AJUDA DE VOCES
TENHO UMA PLANILHA COM UMA LISTAGEM DE PRODUTOS
GOSTARIA DA AJUDA DE VOCES PARA QUE QUANDO EU PESQUISASSE ALGUM CODIGO DESTA PLANILHA
TAMBEM APARECER UMA IMAGEM COM RESULTADO!
SEGUE EM ANEXO MINHA PLANILHA
ABAIXO MEU CODIGO:
Public GeralResultados As Variant
Private Sub btnPesquisar_Click()
If Me.TextBox1.Text = "" Then
MsgBox ("Digite o que você está procurando!"), vbInformation, "ELÉTRICA SUL."
Else
Call PesquisaPersonalizada(Me.TextBox1.Text)
End If
End Sub
Private Sub SpinButton1_Change()
Dim Linha As Long
Dim Total As Long
Total = Me.SpinButton1.Max + 1
Linha = GeralResultados(Me.SpinButton1.Value)
Me.LabelContador.Caption = Me.SpinButton1.Value + 1 & " de " & Total
Me.TextBox2.Text = Plan1.Cells(Linha, 1).Value
Me.TextBox3.Text = Plan1.Cells(Linha, 2).Value
Me.TextBox4.Text = Plan1.Cells(Linha, 3).Value
Me.TextBox5.Text = Plan1.Cells(Linha, 4).Value
Me.TextBox6.Text = Plan1.Cells(Linha, 5).Value
Me.TextBox7.Text = Plan1.Cells(Linha, 6).Value
Me.TextBox8.Text = Plan1.Cells(Linha, 7).Value
Me.TextBox9.Text = Plan1.Cells(Linha, 8).Value
Me.TextBox10.Text = Plan1.Cells(Linha, 9).Value
Me.TextBox11.Text = Plan1.Cells(Linha, 10).Value
Me.TextBox12.Text = Plan1.Cells(Linha, 11).Value
Me.TextBox13.Text = Plan1.Cells(Linha, 12).Value
Me.TextBox14.Text = Plan1.Cells(Linha, 13).Value
Me.TextBox15.Text = Plan1.Cells(Linha, 14).Value
Me.TextBox16.Text = Plan1.Cells(Linha, 15).Value
End Sub
Private Sub PesquisaPersonalizada(ByVal Pesquisado As String)
Dim Pesquisa As Range
Dim Primeira As String
Dim Resultado As String
Set Pesquisa = Plan1.Cells.Find(What:=Pesquisado, After:=Range("A3"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not Pesquisa Is Nothing Then
Primeira = Pesquisa.Address
Resultado = Pesquisa.Row
Do
Set Pesquisa = Plan1.Cells.FindNext(After:=Pesquisa)
If Not Pesquisa.Address Like Primeira Then
Resultado = Resultado & ";" & Pesquisa.Row
End If
Loop Until Pesquisa.Address Like Primeira
GeralResultados = Split(Resultado, ";")
Me.SpinButton1.Max = UBound(GeralResultados)
Me.SpinButton1.Enabled = True
Me.LabelContador.Caption = "1 de " & UBound(GeralResultados) + 1
Me.TextBox2.Text = Plan1.Cells(GeralResultados(0), 1).Value
Me.TextBox3.Text = Plan1.Cells(GeralResultados(0), 2).Value
Me.TextBox4.Text = Plan1.Cells(GeralResultados(0), 3).Value
Me.TextBox5.Text = Plan1.Cells(GeralResultados(0), 4).Value
Me.TextBox6.Text = Plan1.Cells(GeralResultados(0), 5).Value
Me.TextBox7.Text = Plan1.Cells(GeralResultados(0), 6).Value
Me.TextBox8.Text = Plan1.Cells(GeralResultados(0), 7).Value
Me.TextBox9.Text = Plan1.Cells(GeralResultados(0), 8).Value
Me.TextBox10.Text = Plan1.Cells(GeralResultados(0), 9).Value
Me.TextBox11.Text = Plan1.Cells(GeralResultados(0), 10).Value
Me.TextBox12.Text = Plan1.Cells(GeralResultados(0), 11).Value
Me.TextBox13.Text = Plan1.Cells(GeralResultados(0), 12).Value
Me.TextBox14.Text = Plan1.Cells(GeralResultados(0), 13).Value
Me.TextBox15.Text = Plan1.Cells(GeralResultados(0), 14).Value
Me.TextBox16.Text = Plan1.Cells(GeralResultados(0), 15).Value
Me.TextBox17.Text = Plan1.Cells(GeralResultados(0), 30).Value
Else
Me.SpinButton1.Enabled = False
Me.LabelContador.Caption = ""
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.TextBox7.Text = ""
Me.TextBox8.Text = ""
Me.TextBox9.Text = ""
Me.TextBox10.Text = ""
Me.TextBox11.Text = ""
Me.TextBox12.Text = ""
Me.TextBox13.Text = ""
Me.TextBox14.Text = ""
Me.TextBox15.Text = ""
Me.TextBox16.Text = ""
Me.TextBox17.Text = ""
MsgBox ("Nenhum resultado para '" & Pesquisado & "' foi encontrado."), vbInformation, "ELÉTRICA SUL"
End If
End Sub
Private Sub UserForm_Initialize()
Me.TextBox2.Enabled = Enabled
Me.TextBox3.Enabled = Enabled
Me.TextBox4.Enabled = Enabled
Me.TextBox5.Enabled = Enabled
Me.TextBox6.Enabled = Enabled
Me.TextBox7.Enabled = Enabled
Me.TextBox8.Enabled = Enabled
Me.TextBox9.Enabled = Enabled
Me.TextBox10.Enabled = Enabled
Me.TextBox11.Enabled = Enabled
Me.TextBox12.Enabled = Enabled
Me.TextBox13.Enabled = Enabled
Me.TextBox14.Enabled = Enabled
Me.TextBox15.Enabled = Enabled
Me.TextBox16.Enabled = Enabled
Me.TextBox17.Enabled = Enabled
Me.SpinButton1.Enabled = False
Me.LabelContador.Caption = " "
End Sub
GOSTARIA DA AJUDA DE VOCES
TENHO UMA PLANILHA COM UMA LISTAGEM DE PRODUTOS
GOSTARIA DA AJUDA DE VOCES PARA QUE QUANDO EU PESQUISASSE ALGUM CODIGO DESTA PLANILHA
TAMBEM APARECER UMA IMAGEM COM RESULTADO!
SEGUE EM ANEXO MINHA PLANILHA
ABAIXO MEU CODIGO:
Public GeralResultados As Variant
Private Sub btnPesquisar_Click()
If Me.TextBox1.Text = "" Then
MsgBox ("Digite o que você está procurando!"), vbInformation, "ELÉTRICA SUL."
Else
Call PesquisaPersonalizada(Me.TextBox1.Text)
End If
End Sub
Private Sub SpinButton1_Change()
Dim Linha As Long
Dim Total As Long
Total = Me.SpinButton1.Max + 1
Linha = GeralResultados(Me.SpinButton1.Value)
Me.LabelContador.Caption = Me.SpinButton1.Value + 1 & " de " & Total
Me.TextBox2.Text = Plan1.Cells(Linha, 1).Value
Me.TextBox3.Text = Plan1.Cells(Linha, 2).Value
Me.TextBox4.Text = Plan1.Cells(Linha, 3).Value
Me.TextBox5.Text = Plan1.Cells(Linha, 4).Value
Me.TextBox6.Text = Plan1.Cells(Linha, 5).Value
Me.TextBox7.Text = Plan1.Cells(Linha, 6).Value
Me.TextBox8.Text = Plan1.Cells(Linha, 7).Value
Me.TextBox9.Text = Plan1.Cells(Linha, 8).Value
Me.TextBox10.Text = Plan1.Cells(Linha, 9).Value
Me.TextBox11.Text = Plan1.Cells(Linha, 10).Value
Me.TextBox12.Text = Plan1.Cells(Linha, 11).Value
Me.TextBox13.Text = Plan1.Cells(Linha, 12).Value
Me.TextBox14.Text = Plan1.Cells(Linha, 13).Value
Me.TextBox15.Text = Plan1.Cells(Linha, 14).Value
Me.TextBox16.Text = Plan1.Cells(Linha, 15).Value
End Sub
Private Sub PesquisaPersonalizada(ByVal Pesquisado As String)
Dim Pesquisa As Range
Dim Primeira As String
Dim Resultado As String
Set Pesquisa = Plan1.Cells.Find(What:=Pesquisado, After:=Range("A3"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not Pesquisa Is Nothing Then
Primeira = Pesquisa.Address
Resultado = Pesquisa.Row
Do
Set Pesquisa = Plan1.Cells.FindNext(After:=Pesquisa)
If Not Pesquisa.Address Like Primeira Then
Resultado = Resultado & ";" & Pesquisa.Row
End If
Loop Until Pesquisa.Address Like Primeira
GeralResultados = Split(Resultado, ";")
Me.SpinButton1.Max = UBound(GeralResultados)
Me.SpinButton1.Enabled = True
Me.LabelContador.Caption = "1 de " & UBound(GeralResultados) + 1
Me.TextBox2.Text = Plan1.Cells(GeralResultados(0), 1).Value
Me.TextBox3.Text = Plan1.Cells(GeralResultados(0), 2).Value
Me.TextBox4.Text = Plan1.Cells(GeralResultados(0), 3).Value
Me.TextBox5.Text = Plan1.Cells(GeralResultados(0), 4).Value
Me.TextBox6.Text = Plan1.Cells(GeralResultados(0), 5).Value
Me.TextBox7.Text = Plan1.Cells(GeralResultados(0), 6).Value
Me.TextBox8.Text = Plan1.Cells(GeralResultados(0), 7).Value
Me.TextBox9.Text = Plan1.Cells(GeralResultados(0), 8).Value
Me.TextBox10.Text = Plan1.Cells(GeralResultados(0), 9).Value
Me.TextBox11.Text = Plan1.Cells(GeralResultados(0), 10).Value
Me.TextBox12.Text = Plan1.Cells(GeralResultados(0), 11).Value
Me.TextBox13.Text = Plan1.Cells(GeralResultados(0), 12).Value
Me.TextBox14.Text = Plan1.Cells(GeralResultados(0), 13).Value
Me.TextBox15.Text = Plan1.Cells(GeralResultados(0), 14).Value
Me.TextBox16.Text = Plan1.Cells(GeralResultados(0), 15).Value
Me.TextBox17.Text = Plan1.Cells(GeralResultados(0), 30).Value
Else
Me.SpinButton1.Enabled = False
Me.LabelContador.Caption = ""
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.TextBox7.Text = ""
Me.TextBox8.Text = ""
Me.TextBox9.Text = ""
Me.TextBox10.Text = ""
Me.TextBox11.Text = ""
Me.TextBox12.Text = ""
Me.TextBox13.Text = ""
Me.TextBox14.Text = ""
Me.TextBox15.Text = ""
Me.TextBox16.Text = ""
Me.TextBox17.Text = ""
MsgBox ("Nenhum resultado para '" & Pesquisado & "' foi encontrado."), vbInformation, "ELÉTRICA SUL"
End If
End Sub
Private Sub UserForm_Initialize()
Me.TextBox2.Enabled = Enabled
Me.TextBox3.Enabled = Enabled
Me.TextBox4.Enabled = Enabled
Me.TextBox5.Enabled = Enabled
Me.TextBox6.Enabled = Enabled
Me.TextBox7.Enabled = Enabled
Me.TextBox8.Enabled = Enabled
Me.TextBox9.Enabled = Enabled
Me.TextBox10.Enabled = Enabled
Me.TextBox11.Enabled = Enabled
Me.TextBox12.Enabled = Enabled
Me.TextBox13.Enabled = Enabled
Me.TextBox14.Enabled = Enabled
Me.TextBox15.Enabled = Enabled
Me.TextBox16.Enabled = Enabled
Me.TextBox17.Enabled = Enabled
Me.SpinButton1.Enabled = False
Me.LabelContador.Caption = " "
End Sub