如何提取TXT文本中的数据到EXCLE中?

发布网友

我来回答

1个回答

热心网友

根据你的截图,大概可以用如下的方式做出来~Ia、Ib、Ic.....一直到f,先写到excel 中,有问题再提出。

Sub read_txt()

j = 1

n = Cells(1, Columns.Count).End(xlToLeft).Column

Filename = "C:\Users\Administrator\Desktop\1.txt"

Open Filename For Input As #1

Do While Not EOF(1)

Line Input #1, mystr

If Trim(mystr) <> "" Then

j = j + 1

arr = Split(mystr, " ")

Cells(j, 1) = arr(0) & " " & arr(1)

For i = 2 To n

Cells(j, i) = Application.Substitute(arr(i), Cells(1, i) & ":", "")

Next

End If

Loop

Close #1

End Sub

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com