bonescoster
New Member
- Joined
- Mar 16, 2015
- Messages
- 18
Good Day Excel Masters,
I have a bit of code I could use your expert opinions on fixing. I have a Macro created to export one sheet of a workbook as a CSV file. It is used as an upload, but the site it is uploaded to is crazy picky and does not like the comma at the end of row 1.
The first row of the excel sheet has data in columns A:E but each additional row has data in columns A:F. Therefore there is a trailing comma at the end of the first row when looking at the exported CSV in notepad.
Is there a way to have the macro remove the trailing comma when saving the CSV?
Here is the code I have in place now:
Thank you in advance for your help.
I have a bit of code I could use your expert opinions on fixing. I have a Macro created to export one sheet of a workbook as a CSV file. It is used as an upload, but the site it is uploaded to is crazy picky and does not like the comma at the end of row 1.
The first row of the excel sheet has data in columns A:E but each additional row has data in columns A:F. Therefore there is a trailing comma at the end of the first row when looking at the exported CSV in notepad.
Is there a way to have the macro remove the trailing comma when saving the CSV?
Here is the code I have in place now:
VBA Code:
Sub Export()
'Define Destination File Path
ExpDir = "\Uploads\" & Format(Range("WDate").Value, "yyyymm") & " Upload.csv"
'Copy Sheet to New Book
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlManual
Sheets("ACH Upload").Select
Sheets("ACH Upload").Copy
'Select All, Remove Formulas, Make Text
Cells.Select
Selection.NumberFormat = "@"
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'Save New Book
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & ExpDir, FileFormat:=xlCSV, CreateBackup:=False
ActiveWindow.Close
'Display Confirmation MSG Box
MsgBox "Data has been exported to: " & ExpDir
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlAutomatic
End Sub
Thank you in advance for your help.