Hi all, in need of some help to import new data into new column. Currently, Ive only managed to import the data but with every new data, they are stacked below. I need them to be in a new column. Eg. data1 A2:B2, data2 D2:E2, etc...
Also, is it possible to import the filename of the import data at the row before the data? Eg. A1, D1, etc...
Ouble
Also, is it possible to import the filename of the import data at the row before the data? Eg. A1, D1, etc...
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.Range("A" & wsDst.Rows.Count).End(xlUp).Offset(2)
ActiveSheet.UsedRange.Resize(, 2).Copy rngDst
FN = Dir()
ActiveWorkbook.Close False
Loop
End Sub
Ouble