PDA

View Full Version : Sleeper: Importing multiple files to excel



Einsener37
05-07-2020, 08:30 AM
Hi!
I'm complete beginner in VBA, but i see it can be used in excel.
I would like to import all files from folder, place each file in different working sheet and change sheet name according to file name.
I found code like that, but it doesn't work.


Sub LoopAllFilesInAFolder()
'Loop through all files in a folder
Dim fileName As Variant
fileName = Dir("C:\Users\Kasutaja\Dropbox\MJ")
While fileName <> ""
'Insert the actions to be performed on each file
'This example will print the file name to the immediate window
Debug.Print fileName
Windows(fileName).Activate
'Set the fileName to the next file
fileName = Dir
Wend
End Sub

How should i change it?
Thanks!