Sub Botão4_Clique()
Dim contador, col As Integer
Dim valor, PastaAtual, NomeDoArquivo, NomeCompletoDoArquivo As String
Dim Busca As Range
contador = 0
col = 1
ThisWorkbook.Worksheets("Plan1").Activate
Do While Cells(1, col).Value <> ""
Cells(1, col).Select
valor = Cells(1, col).Value
PastaAtual = Application.ActiveWorkbook.Path
NomeDoArquivo = "teste.xlsx"
NomeCompletoDoArquivo = PastaAtual + "\" + NomeDoArquivo
Workbooks.Open (NomeCompletoDoArquivo)
Set Busca = Cells.Find(What:=valor, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ThisWorkbook.Worksheets("Plan1").Activate
Cells(1, col).Activate
Set tbl = ActiveCell
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Select
Selection.Copy
Workbooks(NomeCompletoDoArquivo).Select
ActiveSheet.Paste
Application.CutCopyMode = False
contador = contador + 1
col = col + 1
Loop
MsgBox contador
End Sub
What could be wrong? Thank you