|
そのファイルは、一行で一つのデータしかないわけですね ?
そうすると例えば・・
Sub Test_MyTextOP()
Dim MyF As String
Dim FSO As Object, MyTxt As Object
Dim i As Integer, y As Integer, x As Long
ChDir "C:\Temp" '←テキストを保存しているフォルダーのパスに変更
With Application
MyF = .GetOpenFilename("テキストファイル (*.csv; *.txt), *.csv; *.txt")
If MyF = "False" Then Exit Sub
.ScreenUpdating = False
End With
Set FSO = CreateObject("Scripting.FileSystemObject")
x = 2: y = 1
Set MyTxt = FSO.OpenTextFile(MyF, 1)
For i = 1 To 5
MyTxt.SkipLine
Next i
Do Until MyTxt.AtEndOfStream
Cells(x, y).Value = MyTxt.ReadLine
x = x + 1
If x = 3003 Then
x = 2: y = y + 1
End If
Loop
MyTxt.Close
Set MyTxt = Nothing: Set FSO = Nothing
With Application
ChDir .DefaultFilePath
.ScreenUpdating = True
End With
End Sub
|
|