Hi Member,
I have 2 csv files in download folder. I would like to add each csv file twice to current workbook and rename them accordingly. How should I amend the below coding ?
I have 2 csv files in download folder. I would like to add each csv file twice to current workbook and rename them accordingly. How should I amend the below coding ?
VBA Code:
Sub Add_CSV()
Dim wb As Workbook
Dim FSO As Object, Folder As Object, file As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("C:\Users\Username\Downloads\")
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
For Each file In Folder.Files
Set wb = Workbooks.Open(Filename:=file, UpdateLinks:=False, ReadOnly:=True, IgnoreReadOnlyRecommended:=True)
For Each sheet In wb.Sheets
sheet.Copy After:=ThisWorkbook.Sheets(1)
Next
wb.Close False
Next
Sheets(2).Name = "File1_A"
Sheets(3).Name = "File1_B"
Sheets(4).Name = "File2_A"
Sheets(5).Name = "File2_B"
EndSub