■
単純に左側が空白かどうかで1列目を判断。
(A列は左が空白じゃないので除外)
保存フォルダの行にフルパスが入っているとして、該当フォルダが無ければ作成。
Sub Macro() Dim r As Long Dim c As Long Dim FSO Dim TS Dim filName As String Dim foldPath As String Set FSO = CreateObject("Scripting.FileSystemObject") If Selection.Column > 1 Then If Selection.Offset(0, -1).Value = "" Then r = Selection.Row c = Selection.Column While Cells(r, c).Value <> "" foldPath = Cells(r, c).Value If Not FSO.FolderExists(foldPath) Then FSO.CreateFolder foldPath End If While Cells(r + 1, c).Value <> "終了" r = r + 1 filName = Cells(r, c).Value Set TS = FSO.OpenTextFile(foldPath & "\" & filName, 2, True) r = r + 1 While Cells(r, c).Value <> "" TS.WriteLine (Cells(r, c).Value) r = r + 1 Wend TS.Close Wend c = c + 1 r = Selection.Row Wend Else MsgBox "正しいセルを選択してください" End If Else MsgBox "正しいセルを選択してください" End If Set FSO = Nothing End Sub