SWAY14
New Member
- Joined
- Jul 27, 2022
- Messages
- 15
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- MacOS
Hello,
I have been at this for a few days now and nothing. does anyone know how to remove the trailing commas from a csv file while exporting excel sheet. I have a macro that works fine but when I open the csv file with notepad or textedit I can see the 3 commas at the end of the last cell since the header row goes to CQ and my information will always stop at Cn I only need 1 of these 3 commas after the 2. any help will be grateful!
VBA code
Sub Thistheone()
'
' Macro3 Macro
'
'
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
ActiveWindow.Close True
End Sub
Output file
name,number,individual_first_name,individual_middle_initial,individual_last_name,site_id,individual_gender_id,individual_date_of_birth,individual_title_id,individual_language_id,individual_record_drop_down_id,individual_notes,home_is_aware,partner_is_aware,individual_is_safety_concern,individual_safety_concern_text,individual_is_financial_concern,individual_financial_concern_text,individual_speaks_english,tax_schedule_id,individual_user_defined_country_id,individual_text_1,individual_text_2,individual_text_3,individual_text_4,individual_text_5,individual_text_6,individual_text_7,individual_text_8,individual_drop_down_1_id,individual_drop_down_2_id,individual_drop_down_3_id,individual_drop_down_4_id,individual_drop_down_5_id,individual_drop_down_6_id,individual_drop_down_7_id,individual_drop_down_8_id,individual_drop_down_9_id,individual_drop_down_10_id,individual_drop_down_11_id,individual_drop_down_12_id,individual_checkbox_1,individual_checkbox_2,individual_checkbox_3,individual_checkbox_4,individual_checkbox_5,individual_date_1,individual_date_2,individual_date_3,individual_date_4,individual_date_5,individual_memo_1,individual_memo_2,main_contact_type_id,email_contact_type_id,general_communication_method,email_detail_contact_type_id,email_contact,email_extension,email_is_use_contact,email_comm_instructions,email_in_main_contact,home_contact_type_id,home_contact,home_extension,home_is_use_contact,home_comm_instructions,home_in_main_contact,mobile_contact_type_id,mobile_contact,mobile_extension,mobile_is_use_contact,mobile_comm_instructions,mobile_in_main_contact,work_contact_type_id,work_contact,work_extension,work_is_use_contact,work_comm_instructions,work_in_main_contact,individual_address_line_1,individual_address_line_2,individual_address_line_3,individual_address_drop_down_id,individual_address_county,individual_address_country_id,individual_address_p_code,preenrollment_reason_id,service_id,case_service_group_id,informal_series_id,worker_id,preenrollment_drop_down_1_id,preenrollment_priority_id,preenrollment_notes
individual_pre_enrollment,1,Testing,,Testing,1,2,2007-05-23,,1,,,,,FALSE,,,,,,,4.30E+10,,,testing testing,,4testing,Private Residence,,14,,7,4,4,,,,15,,,,,,,,,,,2022-07-19,,,,Na,,,,3,testing@gmail.com,TRUE,,,,,,,,,2,testing5,,TRUE,,,,,,,,,testing,testing,33,testing,196,21221,68,1065,,,,,2,,,
I have been at this for a few days now and nothing. does anyone know how to remove the trailing commas from a csv file while exporting excel sheet. I have a macro that works fine but when I open the csv file with notepad or textedit I can see the 3 commas at the end of the last cell since the header row goes to CQ and my information will always stop at Cn I only need 1 of these 3 commas after the 2. any help will be grateful!
VBA code
Sub Thistheone()
'
' Macro3 Macro
'
'
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
ActiveWindow.Close True
End Sub
Output file
name,number,individual_first_name,individual_middle_initial,individual_last_name,site_id,individual_gender_id,individual_date_of_birth,individual_title_id,individual_language_id,individual_record_drop_down_id,individual_notes,home_is_aware,partner_is_aware,individual_is_safety_concern,individual_safety_concern_text,individual_is_financial_concern,individual_financial_concern_text,individual_speaks_english,tax_schedule_id,individual_user_defined_country_id,individual_text_1,individual_text_2,individual_text_3,individual_text_4,individual_text_5,individual_text_6,individual_text_7,individual_text_8,individual_drop_down_1_id,individual_drop_down_2_id,individual_drop_down_3_id,individual_drop_down_4_id,individual_drop_down_5_id,individual_drop_down_6_id,individual_drop_down_7_id,individual_drop_down_8_id,individual_drop_down_9_id,individual_drop_down_10_id,individual_drop_down_11_id,individual_drop_down_12_id,individual_checkbox_1,individual_checkbox_2,individual_checkbox_3,individual_checkbox_4,individual_checkbox_5,individual_date_1,individual_date_2,individual_date_3,individual_date_4,individual_date_5,individual_memo_1,individual_memo_2,main_contact_type_id,email_contact_type_id,general_communication_method,email_detail_contact_type_id,email_contact,email_extension,email_is_use_contact,email_comm_instructions,email_in_main_contact,home_contact_type_id,home_contact,home_extension,home_is_use_contact,home_comm_instructions,home_in_main_contact,mobile_contact_type_id,mobile_contact,mobile_extension,mobile_is_use_contact,mobile_comm_instructions,mobile_in_main_contact,work_contact_type_id,work_contact,work_extension,work_is_use_contact,work_comm_instructions,work_in_main_contact,individual_address_line_1,individual_address_line_2,individual_address_line_3,individual_address_drop_down_id,individual_address_county,individual_address_country_id,individual_address_p_code,preenrollment_reason_id,service_id,case_service_group_id,informal_series_id,worker_id,preenrollment_drop_down_1_id,preenrollment_priority_id,preenrollment_notes
individual_pre_enrollment,1,Testing,,Testing,1,2,2007-05-23,,1,,,,,FALSE,,,,,,,4.30E+10,,,testing testing,,4testing,Private Residence,,14,,7,4,4,,,,15,,,,,,,,,,,2022-07-19,,,,Na,,,,3,testing@gmail.com,TRUE,,,,,,,,,2,testing5,,TRUE,,,,,,,,,testing,testing,33,testing,196,21221,68,1065,,,,,2,,,