Hi,
I have this vba that works well but you need to update the path everytime. i wanted to update it to have it using the current path of the active workbook but couldn't make it work.
I have tried many options with the activeworkbook.path but couldn't make it work. Any idea ?
Sub CombineWorkbooks()
Dim Path As String
Path = "N:\ABC\"
Dim FileName As String
FileName = Dir(Path & "*.csv")
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While FileName <> ""
Workbooks.Open Path & FileName
For Each ws In ActiveWorkbook.Sheets
ws.Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
Next ws
Workbooks(FileName).Close
FileName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I have this vba that works well but you need to update the path everytime. i wanted to update it to have it using the current path of the active workbook but couldn't make it work.
I have tried many options with the activeworkbook.path but couldn't make it work. Any idea ?
Sub CombineWorkbooks()
Dim Path As String
Path = "N:\ABC\"
Dim FileName As String
FileName = Dir(Path & "*.csv")
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While FileName <> ""
Workbooks.Open Path & FileName
For Each ws In ActiveWorkbook.Sheets
ws.Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
Next ws
Workbooks(FileName).Close
FileName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub