Here is a copy of my code. I hope this helps. Thanks to all for tyring to help.
code:
Sub CreateCSVFile()
Application.ScreenUpdating = False
Sheets("Sheet2").Select
Dim MyPath As String, MyFile As String, ThisFile As String
'MyPath = "\\BI\whg_bi\datacollection\pmsdatafiles\FSPMS\Unprocessed" '.... Change when correct folder location is decided on.
MyPath = ThisWorkbook.Path '... This is used for testing
MyFile = Sheets("Segmentation RevPAR").Range("AI1").Value & PropNum & "Segmentation RevPAR.txt"
ThisFile = MyPath & Application.PathSeparator & MyFile
'Delete Prior copy of the file
On Error Resume Next
Kill (ThisFile)
On Error GoTo 0
'Open the file
Open ThisFile For Output As #1
intLastRow = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
'Write out the CSV file
For j = 1 To intLastRow
Print #1, Cells(j, 1).Value & "," & Cells(j, 2).Value & "," & Cells(j, 3).Value & "," & Cells(j, 4).Value & "," & Cells(j, 5).Value & "," _
& Cells(j, 6).Value & "," & Cells(j, 7).Value & "," & Cells(j, 8).Value & "," & Cells(j, 9).Value & "," & Cells(j, 10).Value & "," _
& Cells(j, 11).Value & "," & Cells(j, 12).Value & "," & Cells(j, 13).Value & "," & Cells(j, 14).Value & "," & Cells(j, 15).Value & "," _
& Cells(j, 16).Value & "," & Cells(j, 17).Value & "," & Cells(j, 18).Value & "," & Cells(j, 19).Value & "," & Cells(j, 20).Value & "," _
& Cells(j, 21).Value & "," & Cells(j, 22).Value & "," & Cells(j, 23).Value & "," & Cells(j, 24).Value & "," & Cells(j, 25).Value & "," _
& Cells(j, 26).Value & "," & Cells(j, 27).Value
Next j
Close #1
MsgBox "The file " & MyFile & " was successfully created and placed in the assigned folder."
End Sub
Rupert