Boa noite, eu estou fazendo um botão buscar. Ele deve buscar pelo telefone, na planilha que seria o banco de dados dos clientes o telefone que eu digitei no campo da busca que fica acima do botão na célula F14 da planilha "Cadastro". Tentei usar
macro, mas ele copia o valor e não deixa genérico. Então tentei colocar a função .find, mas ele acusa um erro '91' e não consegui encontrar nenhuma solução na internet. Segue como está meu código. Obs: Sou iniciante no VBA.
Sub buscaCliente2()
'
' buscaCliente2 Macro
'
'
Sheets("Cadastro").Select
campoBusca = Range("F14").Value
Cells.Find(What:="campoBusca", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'Sheets("Banco de Clientes").Select
'Cells.FindNext(After:=ActiveCell).Activate
lin = ActiveCell.Row
codigo = Cells(lin, 1)
nome = Cells(lin, 2)
telFixo = Cells(lin, 3)
telCel = Cells(lin, 4)
endereco = Cells(lin, 5)
Email = Cells(lin, 6)
debito = Cells(lin, 7)
recebido = Cells(lin, 8)
falta = Cells(lin, 9)
Sheets("Cadastro").Select
Range("D6") = nome
Range("D8") = telFixo
Range("D10") = telCel
Range("D12") = endereco
Range("D14") = Email
Range("D16") = debito
Range("D18") = recebido
Range("D6,D8,D10,D12,D14,D16,D18").Select
Range("D18").Activate
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("F14").Select
Selection.ClearContents
End Sub