可以使用如下的代码,复制如下代码到VBA模块中运行即可。
如下代码代表4行4列,如果其余行或列数则可更改相应的数字。
具体步骤如下:
打开office excel;
Alt+F11打开VBA编辑器;
复制如下代码到模块中;
F5运行该模块;
按照提示进行如下步骤即可。
Sub xxx()
Dim myFile As String
Dim myText As String
Dim myString As String
Dim i As Single
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
.AllowMultiSelect = False
myFile = .SelectedItems(1)
End With
myText = Dir(myFile & "\" & "*.txt")
Do While Len(myText) <> 0
Open myFile & "\" & myText For Input As #1
myText = Split(Split(VBA.StrConv(InputB(LOF(1), 1), vbUnicode), Chr(10))(3), vbTab)(3) '4行4列,如果其余行或列数则更改相应的数字
Debug.Print myText
Close
myText = Dir
Loop
End Sub