Macro – Adding double quotes for all values in a column in Excel Spreadsheet

Scenario:

I have Excel spreadsheet file, which contains one or more columns and rows.  I want to select a particular column, so that all values in that column should be placed within double  quotes.  That is, it the value is xyz, it should become “xyz”.    This should happen even when I select a particular cell.  When I select a particular cell in a column, the values in the whole column should be updated in such a way that, the values should be enclosed within double quotes.

Macro for the above scenario is,

Sub doublequotes()

Dim tmp_jsn
Dim iLastRow As Long
Dim i As Long
With ActiveCell
iLastRow = Cells(Rows.Count, .Column).End(xlUp).Row
For i = 1 To iLastRow

tmp_jsn = Cells(i, .Column).Value

tmp_jsn = “””” + tmp_jsn + “”””
Cells(i, .Column).Value = tmp_jsn

Next i

End With
End Sub
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: