Sub Import_Txt()
On Error Resume Next
Dim myPath, myTxt As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
.AllowMultiSelect = False
myPath = .SelectedItems(1)
End With
myTxt = Dir(myPath & "\" & "*.txt")
Do While Len(myTxt) <> 0
Worksheets.Add
ActiveSheet.Name = Left(myTxt, Len(myTxt) - 4)
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & myPath & "\" & myTxt, Destination:=Range("$A$1"))
.CommandType = 0
.Name = Left(myTxt, Len(myTxt) - 4)
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
myTxt = Dir
Loop
End Sub
追é®
æ¨å¥½ è½ç¶å¯ä»¥å并 ä¸è¿éæ©å°æ件夹åç¹è¿å»å¸æå¯ä»¥çå°txtæ件 è¿æ ·æè¿å¯ä»¥å»æä¸äºä¸æ³å并ç å¸æå修订ä¸ä¸
å·²è§£å³ è°¢è°¢æ¨ç帮å©
æ¥èªï¼æ±å©å¾å°çåç