Import CSV File into existing table

Status
Not open for further replies.

Elifly

New Member
Joined
Oct 12, 2020
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hey everyone :)

I'm looking for a VBA for importing CSV Files to an existing workbook.

- It lets me pick multiple CSV file via an Open File dialogue
- The CSV File should be copied to the last written column (end of the existing table)
- The CSV 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!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Duplicate Import CVS File into existing table

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top