need help in vba for compile the all excel file data in one master file.

nkashyap3

New Member
Joined
Jun 27, 2019
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
Hi need help in vba code for complied the data of all excel files which is available in folder , there 3 tab in each sheet, I want to compiled only details tab data except header.
in two condition files name and files count will change every month,

I have done but when copy the data there missing some row after copy paste.


Sub CopyData()
Windows("Time Entry Compliance Report Japan (JPN15) Template.xlsx").Activate

Application.ScreenUpdating = False
Dim desWS As Worksheet, srcWB As Workbook, LastRow As Long
Set desWS = ActiveWorkbook.Sheets("Data")
Dim FolderName As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
FolderName = .SelectedItems(1) & "\"
End With
ChDir FolderName
strExtension = Dir("*.xlsx")
Do While strExtension <> ""
Set srcWB = Workbooks.Open(FolderName & strExtension)
With srcWB.Sheets("Details")
.Rows(2).Copy desWS.Cells(1, 1)
LastRow = desWS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.UsedRange.Offset(2, 0).Cells.Copy desWS.Cells(LastRow + 1, 1)

End With

srcWB.Close False
strExtension = Dir


Loop
Application.ScreenUpdating = True
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,215,461
Messages
6,124,954
Members
449,198
Latest member
MhammadishaqKhan

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