Actually I thought this might be the case and might try to work something out.
I think what needs to be done is run an advanced filter on the 'header' column, then dynamically open and name the files.
I'll take a look and hopefully post back.
Option Explicit
Sub test()
Dim arrHeaders
Dim FF()
Dim I As Long
Dim J As Long
Dim LastRow As Long
Dim rng As Range
Dim strToWrite As String
Range("D1:D1411").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("J1"), Unique:=True
LastRow = Range("J65536").End(xlUp).Row
arrHeaders = Range("J2:J" & LastRow)
Range("J:J").ClearContents
ReDim FF(LastRow - 1)
FF(0) = FreeFile
Open "C:\" & Range("H1") & ".DIC" For Output As FF(0)
For I = 1 To UBound(FF)
FF(I) = FreeFile
Open "C:\" & Range("H1") & arrHeaders(I, 1) & ".PRD" For Output As FF(I)
Next I
LastRow = Range("A65536").End(xlUp).Row
For I = 2 To LastRow
Set rng = Range("C" & I)
If rng.Value <> "" Then
If rng.Offset(0, -1) <> "" Then
strToWrite = Chr(34) & rng.Offset(0, 2) & Chr(34) & ";" & rng.Offset(0, -1)
Else
strToWrite = Chr(34) & rng.Offset(0, 2) & Chr(34) & ";" & rng.Offset(0, 5)
End If
For J = 1 To UBound(FF)
If rng.Offset(0, 1) = arrHeaders(J, 1) Then
Print #FF(J), strToWrite
Exit For
End If
Next J
End If
If rng.Offset(0, -1) <> "" Then
strToWrite = rng.Offset(0, -1) & " " & rng & " \" & rng.Offset(0, 2) & "\" & rng.Offset(0, 5)
Print #FF(0), strToWrite
End If
Next I
For I = 0 To 4
Close #FF(I)
Next I
End Sub