If anyone stumbles across this, I've managed to find a solution - although not particularly neat.
I create the .csv using the Option 2 method I described in the original post, but exclude the asterisk from the final line.
Once the .csv has been saved, I loop through the lines to edit adding the commas where necessary and then amend the final line to add the asterisk. line.
Dim L As Long
For L = 1 To csv_row - 2
Dim EachLine As String
EachLine = CSV_Create.Cells(L, 1).Value & "," & CSV_Create.Cells(L, 2).Value & "," & CSV_Create.Cells(L, 3).Value & "," & CSV_Create.Cells(L, 4).Value & ","
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.OpenTextFile(FullName & ".csv", 1)
txt = fsoFile.ReadAll
fsoFile.Close
txt = Split(txt, vbNewLine)
txt(L - 1) = EachLine
Set fsoFile = fso.OpenTextFile(FullName & ".csv", 2)
fsoFile.Write Join(txt, vbNewLine)
fsoFile.Close
Next L
LastLine = BatchNo & "," & Grade & "," & D365Attribute & "," & CSV_Create.Cells(csv_row - 1, 4).Value & "," & CSV_Create.Cells(csv_row - 1, 5).Value & "," & "*"
'Edit last line to put * in
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.OpenTextFile(FullName & ".csv", 1)
txt = fsoFile.ReadAll
fsoFile.Close
txt = Split(txt, vbNewLine)
txt(csv_row - 1 - 1) = LastLine
Set fsoFile = fso.OpenTextFile(FullName & ".csv", 2)
fsoFile.Write Join(txt, vbNewLine)
fsoFile.Close
solution adapted from [URL="https://stackoverflow.com/questions/33120961/how-can-i-edit-a-currently-existing-csv-file-at-specific-rows-in-vba"]
I have to admit, I'm not entirely sure about Scripting.FileSystemObject as I've never used it before, but it works!
Thanks to everyone that took a look at this.
Wahbob
Bookmarks