SWAY14
New Member
- Joined
- Jul 27, 2022
- Messages
- 15
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- 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,
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,