本文主要是介绍VBA批量导入全站仪数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Sub 批量导入数据()
Dim Filename As Variant, myText, S, mArr() As String, narr() As String
Dim i, y As Long, j As Long
Filename = ThisWorkbook.Path & "\1112X.GT7" '指定文件字符串
j = 1
With Worksheets("sheet1")
.Cells.ClearContents
Open Filename For Input As #1
Do While Not EOF(1)
Line Input #1, myText ' 读入一行数据并将其赋予某变量
S = Replace(myText, " ", ",")
mArr = Split(S, ",") '按逗号分开这个字符,循环赋值给单元格
For i = 0 To UBound(mArr)
.Cells(j, i + 1) = mArr(i)
Next i
j = j + 1
Loop
Close #1 ' 关闭文件。
End With
End Sub
这篇关于VBA批量导入全站仪数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!