Sub ImportIJ()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Do
strbook = Application.GetOpenFilename(FileFilter:="Text Files (*.txt),*.txt", Title:="Please select the IJ txt file to open")
If Len(strbook) < 6 Then Exit Sub
If counter > 0 Then MsgBox "You did not select the IJ File (iahs)." & vbCrLf & vbCrLf & "Please select the correct file."
counter = counter + 1
Loop Until UCase(Mid(strbook, InStrRev(strbook, "\") + 1, 4)) = "IAHS" Or UCase(Mid(strbook, InStrRev(strbook, "\") + 1, 2)) = "IJ" Or UCase(Mid(strbook, InStrRev(strbook, "\") + 1, 5)) = "RIAHS"
With Sheets("IJ")
.Range("A1", .Cells(Rows.Count, Columns.Count).Address).Delete
With .QueryTables.Add(Connection:= _
"TEXT;" & strbook & "", Destination:=.Range("$A$1"))
.PreserveFormatting = True
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(3, 2, 2, 1, 2, 1, 2, 2, 2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
For Each nm In ThisWorkbook.Names
nm.Delete
Next nm
For Each cn In ThisWorkbook.Connections
cn.Delete
Next cn
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub