Sub choose_NEWfiles_for_comparison()
Application.ScreenUpdating = False
Dim FilesToOpen
Dim sDelimiter As String
Dim FirstRow As Long
sDelimiter = " "
FilesToOpen = Application.GetOpenFilename _
(FileFilter:="Text Files (*.dat), *.dat", _
Title:="Choose NEW File")
If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
Exit Sub
End If
sName = Mid(FilesToOpen, InStrRev(FilesToOpen, "\") + 1)
FirstRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & FilesToOpen, Destination:=ActiveSheet.Cells(FirstRow, "A"))
.Name = Left(sName, Len(sName) - 4)
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 10
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = " "
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Bookmarks