|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test1()
Dim p As String, f As String, ar(), br, cr
Dim i As Long, j As Long, n As Byte, Sht As Worksheet
Application.ScreenUpdating = False
Application.Calculation = -4135
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.txt")
While Len(f)
Set Sht = Worksheets(Split(f, ".txt")(0))
If Not Sht Is Nothing Then
n = FreeFile
Open p & f For Input As #n
br = Split(StrConv(InputB(LOF(n), #n), vbUnicode), vbCrLf)
Close #n
ReDim ar(UBound(br), UBound(Split(br(0), vbTab)))
For i = LBound(br) To UBound(br)
cr = Split(br(i), vbTab)
For j = LBound(cr) To UBound(cr)
ar(i, j) = cr(j)
Next
Next
Sht.Range("A2").Resize(UBound(ar) + 1, UBound(ar, 2) + 1) = ar
End If
f = Dir
Wend
Set Sht = Nothing
Application.Calculation = -4105
Application.ScreenUpdating = True
Beep
End Sub |
|