可以使用如下的程式碼,複製如下程式碼到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
可以使用如下的程式碼,複製如下程式碼到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