Privite Sub command_click() Sub read_txt() Dim rr As String, n As Integer, xx As Integer xx = InputBox("请输入您读的行号! ", "行号 ", 1) Open "j:\3031.txt " For Input As #1 n = 1 Do While Not EOF(1) Input #1, rr If n = xx Then Sheets(1).Range("a1 ") = rr MsgBox "数据读取成功! " Input #1, rr End If n = n + 1 Loop If xx > n Then MsgBox "指定的文件只有 " & n & "行,数据读取失败 ": GoTo g_exit g_exit: Close #1 End Sub
Private Sub Command_Click()是private不是privite,ok?
Private Sub command_click() End Sub Sub read_txt() End Sub
Sub read_txt()
Dim rr As String, n As Integer, xx As Integer
xx = InputBox("请输入您读的行号! ", "行号 ", 1)
Open "j:\3031.txt " For Input As #1
n = 1
Do While Not EOF(1)
Input #1, rr
If n = xx Then
Sheets(1).Range("a1 ") = rr
MsgBox "数据读取成功! "
Input #1, rr
End If
n = n + 1
Loop
If xx > n Then MsgBox "指定的文件只有 " & n & "行,数据读取失败 ": GoTo g_exit
g_exit:
Close #1
End Sub
请问下能不能把TXT的一类读到我规定的EXCEL单元格中