Jun 21 2019 07:18 AM - edited Jun 21 2019 07:19 AM
Hey Everyone,
I am trying to import a series of csv files into a workbook with worksheets for each csv file. Right now I have figured out how to import all of them into a single worksheet, but I cannot make individuals.
Hope you can help.
Jun 25 2019 12:30 PM
Jun 25 2019 12:40 PM
@trishia11271 All the files are in the same folder, but I am uncertain of the VBA process.
Jun 25 2019 12:51 PM
Hi, try this.
Sub ReadCSV()
Dim strFolder As String
Dim strFile As String
Dim wksTab As Worksheet
Dim wkbSource As Workbook
strFolder = ThisWorkbook.Path & "\"
strFile = Dir(strorder & "*.csv")
Do While strFile <> ""
Debug.Print strFile
Workbooks.OpenText Filename:=strFolder & strFile, Semicolon:=True, local:=True
Set wkbSource = ActiveWorkbook
ThisWorkbook.Worksheets.Add
wkbSource.Worksheets(1).UsedRange.Copy Destination:=ThisWorkbook.ActiveSheet.Range("A1")
wkbSource.Close savechanges:=False
strFile = Dir
Loop
End Sub
or see attachments. Copy all files into a folder an start file start.xlsm
Best regards from germany
Bernd
Jun 25 2019 12:59 PM
@Berndvbatanker Works great, thanks!