I'm not really sure what you are doing.
The topic of your post said "Writing to Text Files" and yet your message says "Writing to Excel".
If I am good at decrypting things (which I hope I am) I think what you REALLY are doing is writing to a text file called an "CSV" file and then IMPORTING that file into Excel so that it automatically spaces everything out.
If that IS the case then all you need to do for headings is simply write the FIRST line to your CSV file containing the headings you want.
ie :
Code:
Open "c:\outfile.csv" for OUTPUT as #1
Print #1, "Profit,Loss,Another Heading,And Another"
Do While not rstSQL.EOF
Print #1, rstSQL("field1") & "," & rstSQL("field2") ...
rstSQL.MoveNext
Loop
Close(1)
So you do exactly what you are normally doing but you need that one extra print #1 line in before you start outputting your data to the file.
Hope I read your question well.