Hi all, Ive got the coding more or less down. However, im trying to figure out if excel could import the 1st 5 excel file's data to one Sheet 1 then the next 5 to Sheet 2, etc...
Currently, its importing everything into one sheet.
Any help is greatly appreciated. Thanks!
Ouble
Currently, its importing everything into one sheet.
Any help is greatly appreciated. Thanks!
Code:
Sub ImportFiles()
Dim Fldr As String, FN As String
Dim wsDst As Worksheet, rngDst As Range
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then
Exit Sub
End If
Fldr = .SelectedItems(1)
End With
Set wsDst = ThisWorkbook.Sheets("Sheet1")
FN = Dir(Fldr & "\*.xls", vbNormal)
Do While FN <> ""
Workbooks.OpenText Filename:=Fldr & "\" & FN, Space:=False
Set rngDst = wsDst.Cells(2, Columns.Count).End(xlToLeft).Offset(0, 2)
ActiveSheet.UsedRange.Resize(, 2).Copy rngDst
wsDst.Cells(2, Columns.Count).End(xlToLeft).Offset(0, -2).Insert xlShiftDown
wsDst.Cells(2, Columns.Count).End(xlToLeft).Offset(-1, -1) = FN
FN = Dir()
ActiveWorkbook.Close False
Loop
End Sub
Ouble