|
Sub Read_MyText()
Dim i As Long, j As Long
Dim MyAry, MyAry2
Dim Ary1, Ary2, Ary3
Dim Ary4, Ary5, Ary6
Dim FSO As Object
Dim MyF As String
Const MyFol As String = _
"C:\Documents and Settings\User\My Documents\"
'↑正確な保存先フォルダーのパスに変更する
MyF = Dir(MyFol & ".BND")
'↑ファイルが見つからないというMsgが出たら小文字の bnd に変えてみる
If MyF = "" Then
MsgBox "拡張子が BND のファイルは見つかりません", 48
Exit Sub
End If
Cells.ClearContents
Set FSO = CreateObject("Scripting.FileSystemObject")
Do
With FSO.OpenTextFile(MyF, 1)
For i = 1 To 6
.SkipLine
Next i
Ary1 = Split(.ReadLine, " ")(2)
Ary2 = Split(.ReadLine, " ")(2)
Ary3 = Split(.ReadLine, " ")(2)
MyAry = Array(Ary1, Ary3, Ary2)
For i = 1 To 3
.SkipLine
Next i
Ary4 = Split(.ReadLine, " ")(2)
Ary5 = Split(.ReadLine, " ")(2)
Ary6 = Split(.ReadLine, " ")(2)
MyAry2 = Array(Ary4, Ary6, Ary5)
j = j + 1
With Cells(j, 1)
.Resize(, 3).Value = MyAry
.Offset(, 3).Resize(, 3).Value = MyAry2
End With
Erase MyAry, MyAry2
.Close
End With
MyF = Dir()
Loop Until MyF = ""
Set FSO = Nothing
End Sub
で、どうでしょーか ? 空白シートを開いて試してみて下さい。
|
|