StevenAncel
New Member
- Joined
- Dec 9, 2015
- Messages
- 38
I feel like my request should be simple.
Here is what my macro does:
1. Copies range from 'Job Type vLookup' tab
2. Opens files from folder listed in A2
3. Adds new tab to opened workbook
4. Paste the information
5. Rename new tab: Job Type vLookup'
6. Save and Close Workbook
7. Loop for each file in folder listed in A2
I need it to dig and run on each excel file found.
For instance:
Master folder > subfolder1 > subfolder2 > excel file <-- Macro runs on that excel file
-------------------------------> subfolder3 > excel file <-- Macro runs on that excel file
-------------------------------> subfolder4 > excel file <-- Macro runs on that excel file
Here is what my macro does:
1. Copies range from 'Job Type vLookup' tab
2. Opens files from folder listed in A2
3. Adds new tab to opened workbook
4. Paste the information
5. Rename new tab: Job Type vLookup'
6. Save and Close Workbook
7. Loop for each file in folder listed in A2
I need it to dig and run on each excel file found.
For instance:
Master folder > subfolder1 > subfolder2 > excel file <-- Macro runs on that excel file
-------------------------------> subfolder3 > excel file <-- Macro runs on that excel file
-------------------------------> subfolder4 > excel file <-- Macro runs on that excel file
Code:
Sub Copy_JobTypevLookup()Dim MyFile As String
Dim sh As Worksheet
Set sh = ThisWorkbook.ActiveSheet
MyPath = "\\ac.local\AC-DFS\UserData\steven.lawson\Desktop\" & Range("A2").Text
MyFile = Dir(MyPath & "\*.xlsx")
Sheets("Job Type vLookup").Select
Range("A1:B1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Sheet1").Activate
Range("A1").Activate
Do While MyFile <> ""
Workbooks.Open Filename:=MyPath & "\" & MyFile
With Sheets(1)
Sheets("Sheet1").Activate
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Columns("A:B").EntireColumn.AutoFit
ActiveSheet.Name = "Job Type vLookup"
Range("A1").Select
End With
Range("A1").Select
ActiveWorkbook.Close True
MyFile = Dir
Loop
End Sub