Stroppiger
New Member
- Joined
- Jun 29, 2021
- Messages
- 3
- Office Version
- 2016
- Platform
- Windows
Hi everyone,
I've got some problems with the vba code, that I found online. I want to import multiple csv files without header into the worksheet "csv_data". The following code imports just one file, even though I select a few. Please tell me where I made a mistake.
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("csv_data")
ActiveSheet.UsedRange.Resize(ActiveSheet.UsedRange.Rows.count - 1).Offset(1, 0).Copy _
Destination:=.Range("A" & lastrow)
lastrow = .UsedRange.Rows.count + 1
End With
ActiveWorkbook.Close True
Next i
End If
End Sub
Thanks in advance
I've got some problems with the vba code, that I found online. I want to import multiple csv files without header into the worksheet "csv_data". The following code imports just one file, even though I select a few. Please tell me where I made a mistake.
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("csv_data")
ActiveSheet.UsedRange.Resize(ActiveSheet.UsedRange.Rows.count - 1).Offset(1, 0).Copy _
Destination:=.Range("A" & lastrow)
lastrow = .UsedRange.Rows.count + 1
End With
ActiveWorkbook.Close True
Next i
End If
End Sub
Thanks in advance