Copy Excel Data from folder to Master workbook

albert2

New Member
Joined
Jul 12, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello Excel expert, I found a code below on the internet to copy a list of 100 workbooks in a folder, But this macro didn't work as I want it to be. Basically, it needs to copy data from Sheet "Export Tab" from rows A4:AP down to whatever lines then copy to the "master tracker workbook". Usually, I do this manually which took me the whole day to complete.

Please Help!

Sub GetDataFromFilesInAFolder()

Dim FPath As String
Dim FName As Variant
Dim ws As Worksheet, wsS As Worksheet
Dim wb As Workbook, wbMaster As Workbook

Set wbMaster = ActiveWorkbook
Application.ScreenUpdating = False

FPath = "C:\Users\Acer\Desktop\Tracker\" ' Set your folder path here
FName = Dir(FPath)

While FName <> ""
Set wb = Workbooks.Open(fileName:=FPath & FName, UpdateLinks:=False, ReadOnly:=True, IgnoreReadOnlyRecommended:=True)
For Each ws In wb.Sheets
If ws.Name = "Export Data" Then
ws.Cells.Copy wbMaster.Sheets(Split(FName, ".")(0)).Range("A1")
End If
Next
'Close wb without saving
wb.Close False
'Set the fileName to the next file
FName = Dir
Wend

End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top