This is the attempt to do so:
Sub GetSheets()
Dim Path As Variant
Dim filename As Variant
Dim sheet As Variant
Path = "C:\Users\Asus\Google Drive\Income Generating\Stock Market\Daily Quotes\PSEGet"
filename = Dir(Path & "\*.csv")
Do While filename <> ""
Workbooks.Open filename:=Path & filename, ReadOnly:=True
For Each sheet In ActiveWorkbook.Sheets
sheet.Copy After:=ThisWorkbook.Sheets(1)
Next sheet
Workbooks(filename).Close
filename = Dir()
Loop
End Sub
When I press the Run Macro button, the file path is recognized, but the copying of the rows of data is not working. This error appears:
These are the files that I want to combine into a master worksheet. Located in one folder:
The files I want to combine are shown here: Sample of CSV file
I came out with a working solution:
The output of the code is here: Compiled File