|
发表于 2012-5-24 07:44
|
显示全部楼层
本楼为最佳答案
本帖最后由 zjdh 于 2012-5-24 07:48 编辑
Sub Macro1()
Dim wj As String
Range("A2:U65536").ClearContents
wj = Dir(ThisWorkbook.Path & "\*.txt")
s = 0: S1 = 1
Do While wj <> ""
s = s + 1
s2 = 0
Open ThisWorkbook.Path & "\" & wj For Input As #s
Do While Not (EOF(s))
Line Input #s, n
s2 = s2 + 1
If s2 > 0 Then
Y = Split(n, ",")
S1 = S1 + 1
For i = 0 To UBound(Y)
Cells(S1, i + 1) = Y(i)
Cells(S1, 21) = Replace(Split(wj, ".")(0), ThisWorkbook.Path, "")
Next i
End If
Loop
Close #s
wj = Dir
Loop
End Sub |
|