Hi Guys
I have this code which consolidates the files from fpath into master file.
i have 20 files in fpath and i have numbered it from 1 to 20.
Everytime i run the macro it picks the file in radom order and consilidates it, how to modify it pick in the same order as its being put in the fpath.
Dim wbData As Workbook, wbMain As Workbook, wsMain As Worksheet, wsData As Worksheet
Dim LR As Long, NR As Long, fPath As String, fName As String
Set wbMain = ThisWorkbook
fPath = "Z:\Demand & Supply\Demand & Supply\3.Color Breakdown 2.0\Sep_Oct'15 Production - Testing\3.Master\"
fName = Dir(fPath & "*.xlsm")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
On Error Resume Next
Do While Len(fName) > 0
If fName <> ThisWorkbook.Name Then
Set wbData = Workbooks.Open(fPath & fName)
For Each wsData In wbData.Worksheets
Set wsMain = wbMain.Sheets(wsData.Name)
If Not wsMain Is Nothing Then
NR = wsMain.Range("A" & Rows.Count).End(xlUp).Row + 1
With wsData
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A4:A" & LR).EntireRow.Copy wsMain.Range("A" & NR)
End With
Set wsMain = Nothing
End If
Next wsData
wbData.Close False
End If
fName = Dir
Loop
Thanks for any assistance
Bookmarks