Code: Select all
Sub ImportCSV()
On Error GoTo Over
LRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Application.ScreenUpdating = False
ActiveSheet.Unprotect
For Each QTable In ActiveSheet.QueryTables
QTable.Delete
Next
InFile = False
ChDir "C:\Users\"
InFile = Application.GetOpenFilename
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & InFile, Destination _
:=Range("A" & LRow))
If InFile = False Then
MsgBox ("You Did Not Choose An Input File")
GoTo Over
End If
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Over:
Application.ScreenUpdating = True
End Sub