'Excel VBA - Button to find information between workbooks
I'm a beginner at VBA and I'm trying to create a button to search for previous data inserted in all workbooks, using information as client name or date see here. Could you help me with some tips? I attached my code until now below. Thanks in advance.
Private Sub data_consulta_Change()
If VBA.Len(data_consulta.Text) = 2 Then
data_consulta = data_consulta + "/"
End If
If VBA.Len(data_consulta.Text) = 5 Then
data_consulta = data_consulta + "/"
End If
End Sub
Private Sub limpar_Click()
cliente_nome = ""
data_consulta = ""
End Sub
Private Sub pesquisar_base_Click()
On Error GoTo Erro
'Dim pesquisa As String
'pesquisa = InputBox("Digite as informações da consulta!", "PESQUISAR")
Dim linha As Double
linha = 1
With Planilha1
Do
linha = linha + 1
If .Cells(linha, 2).Value = pesquisa Or .Cells(linha, 3).Value Or .Cells(linha, 4).Value Then
data_consulta = .Cells(linha, 2).Value
data_consulta = .Cells(linha, 4).Value
Exit Sub
End If
Loop Until .Cells(linha, 2).Value = ""
MsgBox "Informação não encontrada!", vbInformation, "PESQUISA"
End With
Exit Sub
Erro:
MsgBox "Digite as informações da consulta!", cvcritical, "ERRO"
End Sub
Private Sub UserForm_Initialize()
data_consulta = VBA.Date
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub CommandButton1_Click()
'...
End Sub
Private Sub cliente_nome_Change()
'...
End Sub
Private Sub Label1_Click()
'...
End Sub
Private Sub Label2_Click()
'...
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
