How to Import Multiple CSV Files into Separate Worksheets in the Same Workbook in Excel

preview_player
Показать описание
In this tutorial you will learn how to import multiple CSV files into separate worksheets in the same workbook in Excel. Instead of combining the CSV files into one worksheet, you can use a Visual Basic Script in Excel to import multiple CSV files into different tabs. The VB Script will name each Microsoft Excel tab with the same name as the CSV file. Once you have imported the CSV files into the worksheet they can be saved and formatted like any other Excel workbook.

Visual Basic code: It would not let me put it in the description so I put it as a pinned comment.

Check out these programs I use for YouTube

Follow me on social media:
Twitter: @melissaecompton
Instagram: @melissaacompton

This description contains affiliate links and I may be paid a small commission should you purchase using these links.

#melissacompton #msexcel #excel #importcsvfiles
Рекомендации по теме
Комментарии
Автор

VISUAL BASIC CODE:

Sub CombineCsvFiles()
'updated by MelCompton
Dim xFilesToOpen As Variant
Dim I As Integer
Dim xWb As Workbook
Dim xTempWb As Workbook
Dim xDelimiter As String
Dim xScreen As Boolean
On Error GoTo ErrHandler
xScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
xDelimiter = "|"
xFilesToOpen = Files (*.csv), *.csv", , "MelCompton VBA for Excel", , True)
If TypeName(xFilesToOpen) = "Boolean" Then
MsgBox "No files were selected", , "MelCompton VBA for Excel"
GoTo ExitHandler
End If
I = 1
Set xTempWb =
xTempWb.Sheets(1).Copy
Set xWb = Application.ActiveWorkbook
xTempWb.Close False
Do While I < UBound(xFilesToOpen)
I = I + 1
Set xTempWb =
xTempWb.Sheets(1).Move, xWb.Sheets(xWb.Sheets.Count)
Loop
ExitHandler:
Application.ScreenUpdating = xScreen
Set xWb = Nothing
Set xTempWb = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, , "MelCompton VBA for Excel"
Resume ExitHandler
End Sub

MelCompton
Автор

This was the exact thing I needed and I really searched so many yt videos but ..Finally ..I got this...Thanks Melissa for making this.

krishnasahoo
Автор

Well done! I was trying to figure out a good way to combine data for the data analytics certification, and this helped me so much. Thank you!

Fr_dG
Автор

Thank you so very much Melissa. What an amazingly clear and consise video

aodhang
Автор

Thanks @MelCompton this was exactly what i needed!

gruzrin
Автор

Thank you so much for such an amazing tutorial and providing code as well.

bikrampandher
Автор

Well cone Melissa! You made this super easy to follow and helped me import 16 CSV's in less than 5 minutes!

phylum
Автор

This is amazing.... Thank you so much for posting this.

mattbown
Автор

this is extremely helpful! thanks for your efforts!!

salmanmusliman
Автор

THANK YOU SO MUCH this worked perfect I have been trying to figure out how to do this for awhile..

joshuagoodman
Автор

Thank you so much for this! This is amazing!

henryp
Автор

Melissa! Thank you, this is a huge help!!

grantschrof
Автор

Man that was a Great. First time somebody went through all the steps .I was able to do it first try on split screen. I even made a small button on the template ( new for me too ) to run the macro.

hans
Автор

Thank you very much, this was really helpful.

alloy
Автор

This was so great! Thank you so much!

ulrich
Автор

This was perfect, exactly what I needed! Your 5 minute video saved me hours of manual work

jdzfb
Автор

Absolute lifesaver, thank you for code.

bastardboyyeah
Автор

THANK YOU SO MUCH
☺IT HELPED ME A LOT

archanasahoo
Автор

I can not thank you enough. Awesome content!

kmqklwe
Автор

Thank you! this will save me hours of work!

courtneypierone