Hey everyone
I'm looking for a VBA for importing CVS Files to an existing workbook.
- It lets me pick multiple CSV file via an Open File dialogue
- The CVS File should be copied to the last written column (end of the existing table)
- The CVS File could be opened and closed again
I'm sure this has been written hundreds of times, but I can't seem to find a solution that fits my needs best
I have a code that works pretty well besides it copies my file to the top of my workbook
Looking forward to your solutions
Thank you!
I'm looking for a VBA for importing CVS Files to an existing workbook.
- It lets me pick multiple CSV file via an Open File dialogue
- The CVS File should be copied to the last written column (end of the existing table)
- The CVS File could be opened and closed again
I'm sure this has been written hundreds of times, but I can't seem to find a solution that fits my needs best
I have a code that works pretty well besides it copies my file to the top of my workbook
VBA Code:
Sub CSV_Import()
Dim dateien, i, lastrow
lastrow = 1
dateien = Application.GetOpenFilename _
("csv-Dateien (*.csv), *.csv", MultiSelect:=True)
If IsArray(dateien) Then
For i = 1 To UBound(dateien)
Workbooks.Open dateien(i), local:=True
With ThisWorkbook.Sheets(1)
ActiveSheet.UsedRange.Copy Destination:=.Range("A" & lastrow)
lastrow = .UsedRange.Rows.Count + 1
End With
ActiveWorkbook.Close False
Next i
End If
End Sub
Looking forward to your solutions
Thank you!