|
Sub Read_file()
Dim MyF As String, buf As String
Dim Fnum As Long, i As Long
Dim Ary As Variant
Const Ph As String = "C:\analysis\"
MyF = Dir(Ph & "*.txt"): i = 1
Do Until MyF = ""
Fnum = FreeFile()
Open Ph & MyF For Input Access Read As #Fnum
Do Until EOF(Fnum)
Line Input #Fnum, buf
Ary = Split(buf, Chr(9), 4) '区切り文字をタブとし要素数を4とする。
Worksheets("Sheet1").Cells(i, 1).Resize(, 4).Value = Ary
i = i + 1: Erase Ary
Loop
Close #Fnum: MyF = Dir()
Loop
MsgBox "全てのテキストファイルデータを読み込みました", 64
End Sub
で、どうでしょーか ?
|
|