In order to create a dynamic Dashboard I need to compile different file with different sheets in a main workbook. I manage to find a code to extract the files content and copying it into the main workbook.
Problem: the data gets copied, no problem but if I add a table in my main workbook the data get copied until the row "139" and then get copied 1 row after the end of the table.
Sub DIRECT()
Dim fName As String, fPath As String, fPathDone As String
Dim LR As Long, NR As Long
Dim wbData As Workbook, wsMaster As Worksheet, ws As Worksheet
Dim tbl As ListObject
Set wsMaster = ThisWorkbook.Sheets("Master-DIRECT")
With wsMaster
NR = 2
fPath = "xxxxx"
fName = Dir(fPath & "*.xls*")
Do While Len(fName) > 0
If fName <> ThisWorkbook.Name Then
Set wbData = Workbooks.Open(fPath & fName)
For Each ws In wbData.Worksheet
If ws.Name = "Direct" Then
LR = ws.Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A2:A" & LR).EntireRow.Copy .Range("A" & NR)
NR = .Range("A" & .Rows.Count).End(xlUp).Row + 1
End If
Next ws
fName = Dir
End If
Loop
End With
Here is what happening for example
I would like to now if I am misunderstanding something in this code.
Thank you for taking time to read my question.
PS: I know about Power Query, I am trying to find an alternative solution