VBAサンプル
============================================
=== 開始!!===================================
============================================
Sub CSV出力()
'**********************************
'*** 1.定義
'**********************************
'変数宣言
Dim filePath As String
Dim iii As Long
Dim maxRow As Long
Dim fileNo As Integer
'出力先パス設定(エクセルと同じディレクトリに格納)
実行日時 = Format(Date, "yyyymmdd") & "_" & Format(Time, "hhmmss")
filePath = ActiveWorkbook.Path & "\outfile_" & 実行日時 & ".csv"
'最終行の取得
maxRow = Range("B10").End(xlDown).Row
'FreeFile関数で使用可能なファイル番号取得
fileNo = FreeFile
'**********************************
'*** 2.CSVファイル作成処理(カンマ区切りで、ダブルコーテーションがつく)
'**********************************
'データが入っていることをチェック
If Cells(11, "B") = "" Then
MsgBox ("データないため、処理終了")
Exit Sub
End If
'ファイル開く
Open filePath For Output As #fileNo
'最終行までループ(処理は、一行ずつ出力するのみ)
For iii = 11 To maxRow
Write #fileNo, Cells(iii, "B"), Cells(iii, "C")
Next iii
'ファイル閉じる
Close #fileNo
Cells(1, 1).Select
MsgBox ("処理が終了しました")
End Sub
============================================
=== 終了!!===================================
============================================