Sub test()
Dim csvFile As String
Dim ch As Integer
Dim csvStr As String
Dim str() As String
Dim i As Integer
'CSVファイル名
csvFile = "C:\test.csv"
'空いている番号を取得
ch = FreeFile
'CSVファイルオープン
Open csvFile For Input As #ch
'CSVファイル読込
i = 1
Do While Not EOF(1)
'1行読み込む
Line Input #ch, csvStr
'カンマ区切りで配列に格納
str = Split(csvStr, ",")
'セルのレンジを指定して、配列の値をセット
Range(Cells(i, 1), Cells(i, UBound(str) + 1)) = str
i = i + 1
Loop
'ファイルクローズ
Close #ch
End Sub
|