通过Excel宏逐行读取文本文件

时间:2019-12-28 14:42:27

标签: excel vba

我使用下面的代码,但是没有运气,因为数据导出到单个单元格中。 下面是文本文件的代码和链接。

Sub ReadFileLineByLine()
    Dim my_file As Integer
    Dim text_line As String
    Dim file_name As String
    Dim i As Integer

    file_name = "C:\Temp\ISSRPGBB271219_2C.MGBB"

    my_file = FreeFile()
    Open file_name For Input As my_file

    i = 1

    While Not EOF(my_file)
        Line Input #my_file, text_line
        Cells(i, "A").Value = text_line
        i = i + 1
    Wend
End Sub

文本文件链接: https://drive.google.com/open?id=1Z9g1DX_bxosSJEpSyQKL_TMfxr-ZFA9C

0 个答案:

没有答案