I want to use this macro at work.
We sometimes need to look for a certain and unique Code inside multiple excel files that are inside a specific folder., and once the code is found, to copy certain information on that row to another sheet.
I have the whole code done already, the only problem is that the search doesn't include the excel files that are inside a zip folder.
Here goes the whole code
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Dim MyFolder As String
Dim MyFile As String
Dim ws As Worksheet
MyFolder = "C:\Users\Username\Desktop\New Folder"
MyFile = Dir(MyFolder & "\*.xlsx")
ultimalinha = 1000 'Lastrow
Code= UCase(TextBox1.Value)
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
For Each ws In ActiveWorkbook.Worksheets
'Set-up BY
For linha = 1 To ultimalinha
If Worksheets(1).Range("A" & linha).Value = Code Then
Worksheets(1).Range("B" & linha).Cells.Copy
Workbooks("Final-Search.xlsm").Sheets(1).Range("A1").PasteSpecial
Worksheets(1).Range("D" & linha).Cells.Copy
Workbooks("Final-Search.xlsm").Sheets(1).Range("B1").PasteSpecial
End If
Next
'Controlled BY
For linha = 1 To ultimalinha
If Worksheets(2).Range("A" & linha).Value = Code Then
Worksheets(2).Range("B" & linha).Cells.Copy
Workbooks("Final-Search.xlsm").Sheets(1).Range("A2").PasteSpecial
Worksheets(2).Range("D" & linha).Cells.Copy
Workbooks("Final-Search.xlsm").Sheets(1).Range("B2").PasteSpecial
End If
Next
Next ws
'Close Excel Files
Application.DisplayAlerts = False
ActiveWorkbook.Close savechanges:=False
Application.DisplayAlerts = True
MyFile = Dir
Loop
End sub