vba读取txt文件
要求是把每一行的第二个数字读取出来我的代码如下:SubMacro1()''Macro1Macro''DimAAAAsLongDimBBBAsLongBBB=1Open"D...
要求是把每一行的第二个数字读取出来
我的代码如下:
Sub Macro1()
'
' Macro1 Macro
'
'
Dim AAA As Long
Dim BBB As Long
BBB = 1
Open "D:\a.txt" For Input As #1
While Not EOF(1)
AAA = Input(3, #1)
AAA = Input(3, #1)
Cells(BBB, 1) = AAA
BBB = BBB + 1
Wend
Close #1
End Sub
我这个是读取的是第四个到第六个数据。但是不是一行一行读的 展开
我的代码如下:
Sub Macro1()
'
' Macro1 Macro
'
'
Dim AAA As Long
Dim BBB As Long
BBB = 1
Open "D:\a.txt" For Input As #1
While Not EOF(1)
AAA = Input(3, #1)
AAA = Input(3, #1)
Cells(BBB, 1) = AAA
BBB = BBB + 1
Wend
Close #1
End Sub
我这个是读取的是第四个到第六个数据。但是不是一行一行读的 展开
1个回答
展开全部
亲,已经改好了,代码如下:
Sub Macro1()
'
' Macro1 Macro
'
'
Dim AAA As Long
Dim BBB As Long
Dim s As String
BBB = 1
Open "D:\a.txt" For Input As #1
While Not EOF(1)
Line Input #1, s
Cells(BBB, 1) = Mid(s, 2, 1)
BBB = BBB + 1
Wend
Close #1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询