Put Entire Cell Contents Within Double Quotes (")

Kickingkangaroos

New Member
Joined
Sep 2, 2009
Messages
46
Hi All,

I need to create a daily CSV file for upload into a CMS.

However, the format I get my report in is standard .xls - as such, I need to ensure the content is suitable for a CSV.

One of the columns contains text, which (helpfully!) includes commas here and there, as such I need to wrap each of the cells in this column (B) in double quotes (e.g. from Train, Red, with blue, yellow and white trim to "Train, Red, with blue, yellow and white trim") to ensure the CSV uploads correctly.

Is there a quick/easy way to do this for multiple rows?

Many thanks,

Andy
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Andy,

You can use the following to wrap quotation marks around each cell's value in column B:
Code:
Sub tgr()
    
    Dim arrB As Variant: arrB = Intersect(ActiveSheet.UsedRange, [B:B]).Value
    Dim r As Long
    For r = 1 To UBound(arrB, 1)
        arrB(r, 1) = """" & arrB(r, 1) & """"
    Next r
    Intersect(ActiveSheet.UsedRange, [B:B]).Value = arrB
    
End Sub

Hope that helps,
~tigeravatar
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

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