Hi guys,
I having trouble importing only the column a and b. I am importing excel file data (500 of them) into a single sheet and would only like to extract values from 2 columns. I am new to vba and got dumped by this job because our IT guy is in the hospital. My job is on the line
need all the help in the world...
Thank you very much.
Ouble
I having trouble importing only the column a and b. I am importing excel file data (500 of them) into a single sheet and would only like to extract values from 2 columns. I am new to vba and got dumped by this job because our IT guy is in the hospital. My job is on the line
need all the help in the world...
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
MsgBox "cancelled by user"
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 = Union(Range(Columns(1), Columns(2))).Select
Set rngDst = wsDst.Range("A" & wsDst.Rows.Count).End(xlUp).Offset(2)
ActiveSheet.UsedRange.Copy rngDst
FN = Dir()
ActiveWorkbook.Close False
Loop
End Sub
Thank you very much.
Ouble