Here's the long version. 
Sub CopyToCSVWOBlanks()
Dim WS As Worksheet
Dim LastRow As Long
Dim LastCol As Long
Dim A As Long, B As Long
Dim Temp As Variant
Dim FF As Integer
Dim MyFilename As String
'path name
Const Mypath As String = "C:\V10\demo\import\" 'NOTE: must end with "\"
' file name
MyFilename = Sheets(1).Cells(1, 1).Value
'Makes sure the filename ends with ".csv"
If Not Right(MyFilename, 4) = ".csv" Then
MyFilename = MyFilename & ".csv"
End If
Set WS = Worksheets("upload")
With WS
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
LastCol = .UsedRange.Columns.Count
'Stuff the range into an array
Set Temp = .Range(.Cells(1, 1), .Cells(LastRow, LastCol))
'Next open file number
FF = FreeFile
'Open file for writing.
Open Mypath & MyFilename For Output As #FF
'Iterate the array.
For A = 1 To LastRow
If .Cells(A, 1) <> 0 Then
For B = 1 To LastCol - 1
Write #FF, .Cells(A, B);
Next
'Have to seperate last line without a semicolon to get VbCr.
Write #FF, .Cells(A, B)
End If
Next
Close FF
End With
End Sub
Bookmarks