I have downloaded 2 zip files and want to insert the csv files inside zip files to my current worksheet. I want the first csv file from 1st downloaded zip file to rename as Sheet_A and Sheet_B for csv files from 2nd downloaded zip files. When I try to add to my current workbook, csv from 2nd downloaded zip tend to be renamed as Sheet_1. Kindly help on this.
VBA Code:
Sub Addcsv()
Dim Path As String, Filename As String
Dim Sheet As Worksheet
Path = "C:\Users\My\Downloads\"
Filename = Dir(Path & "Report*")
' Disable Screen Updating is used to stop screen flickering and Disable Events is used to avoid interrupted dialog boxes / popups
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy after:=ThisWorkbook.Sheets(2)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
' Resume Screen Updating and Events
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Sheets(2).Name = "Sheet_A"
Sheets(3).Name = "Sheet_B"