how to deal with trailing commas when exporting to csv help im very new to VBA

Status
Not open for further replies.

SWAY14

New Member
Joined
Jul 27, 2022
Messages
15
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
  2. MacOS
Hello, Im new to VBA and I am trying to export sheet 1 to csv but since im importing to a system they do not like trailing commas.
I have my code which does a great job of selecting rows with information but since I am using row 1 as headers and it goes all the way to CQ
but I know that all the other records starting at row 2 will end at CN which leaves me with all rows from row 2 forward with 3 trailing commas at the end. The thing is I really only need 1 of the trailing commas for the system to validate my file. Any help will be amazing!


My code
Sub Thistheone()
'
' Macro3 Macro
'

'
Application.DisplayAlerts = False
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs FileName:= _
"/Users/sway/Desktop/cleint uploads /Testing2.csv", FileFormat:=xlCSVUTF8, _
CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close True



End Sub

what I am trying to fix when exported
from this
1065,,,,,2,,,
to this
1065,,,,,2,
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top