|
Sub zzz()
Dim Filename As Variant, myText, mArr() As String
Dim i As Long, j As Long
Filename = ThisWorkbook.Path & "\新建文本文档.txt"
j = 1
With Sheet1
.Cells.ClearContents
Open Filename For Input As #1
Do While Not EOF(1)
Line Input #1, myText
mArr = Split(myText, " ")
For i = 0 To UBound(mArr)
.Cells(j, i + 1) = mArr(i)
Next i
j = j + 1
Loop
Close #1
End With
zz
End Sub
Sub zz()
ar = [a1].CurrentRegion
ReDim br(1 To UBound(ar), 1 To 3)
For i = 1 To UBound(ar)
If ar(i, 2) = "" Then
s = ar(i, 1): n = 0
Else
m = m + 1: br(m, 2) = ar(i, 1): br(m, 3) = ar(i, 2)
br(m, 1) = Mid(s, 1, 5) & Val(Right(s, 1)) + n: n = n + 1
End If
Next
ReDim cr(1 To m)
For i = 1 To m
cr(i) = br(i, 1) & "," & "00000000" & "," & br(i, 2) & "," & br(i, 3) & "," & "0.0"
Next
s = Join(cr, Chr(10))
Open ThisWorkbook.Path & "\" & "文本.dat" For Output As #1
Print #1, s
Close #1
End Sub
|
|