![]() |
Slight problem - routine to add quotes to a column
Hi,
I'm using the following code to enclose all values in a specific column (Excel column 'CC') in a CSV file (obviously when opened in Excel). Sub Test() Dim RangeFirstColumn As Range Dim i As Range Set RangeFirstColumn = Range("CC2", Range("CC" & Rows.Count).End(xlUp).Address) For Each i In RangeFirstColumn If Len(i.Value) 0 Then i = Chr(34) & i.Value & Chr(34) Next i End Sub The problem is, when I open up the resulting .csv in Notepad, the field in question in each row is now enclosed in three quotation marks instead of the expected one (e.g. """010""" rather than "010"). Could anyone advise me of what changes I need to make to my code? Many thanks. |
Slight problem - routine to add quotes to a column
Since you place quotes in the text in the cell, excel puts in more quotes so
your quotes are retained. http://support.microsoft.com/default...b;en-us;291296 Procedure to export a text file with both comma and quote delimiters in Excel -- Regards, Tom Ogilvy wrote in message oups.com... Hi, I'm using the following code to enclose all values in a specific column (Excel column 'CC') in a CSV file (obviously when opened in Excel). Sub Test() Dim RangeFirstColumn As Range Dim i As Range Set RangeFirstColumn = Range("CC2", Range("CC" & Rows.Count).End(xlUp).Address) For Each i In RangeFirstColumn If Len(i.Value) 0 Then i = Chr(34) & i.Value & Chr(34) Next i End Sub The problem is, when I open up the resulting .csv in Notepad, the field in question in each row is now enclosed in three quotation marks instead of the expected one (e.g. """010""" rather than "010"). Could anyone advise me of what changes I need to make to my code? Many thanks. |
Slight problem - routine to add quotes to a column
Thanks Tom
|
All times are GMT +1. The time now is 09:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com