Copy from 3 CSV files into one worksheet

The solutions I'm finding when I search the web always throw in a bunch of other stuff I don't need, but require interaction. I'm trying to make this a one-click process.

This is just part one.

Open each of 3 csv files, we can call them A.csv, B.csv, and C.csv. They can be opened one at a time or all at once.
Copy from A2:C2 and down.

Range(Range("A2:C2"), Range("A2").End(xlDown)).Copy

Open in new window


Then paste into the workbook called Macro.xlsm, which happens to be open.
Paste to Data!D2.
The other 2 files should paste below that. Note there are blank rows in the CSV files.

Sample project files can be found at www.annetroy.com/eeq

I do not want to have to designate a path name. I would like for the code to use "this folder". The macro.xlsm workbook and CSV files will always be in the same folder.

I will be watching my email in case you have any questions.

I will be posting another question as soon as I've got this one done. I thank you so much in advance for your time!
LVL 22
Anne TroyEast Coast ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
If the CSV files have defined names, this will import the 3 of them...

Sub ImportCSVfiles()

    Dim file As Variant, fileNames As Variant, lastRow As Long
    fileNames = Array("A", "B", "C")
    
    For Each file In fileNames
        With Workbooks.Open(file & ".csv")
            With .ActiveSheet
                lastRow = .Cells(Rows.Count, "A").End(xlUp).Row
                .Range("A2:C" & lastRow).Copy ThisWorkbook.Worksheets("Data").Cells(Rows.Count, "D").End(xlUp).Offset(1, 0)
            End With
            .Close False
        End With
    Next
    
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anne TroyEast Coast ManagerAuthor Commented:
That is awesome. I needed only to add:

    ChDir ActiveWorkbook.Path

before opening the files.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.