Macro to place quotation marks before and after text in all cells

S

suestew

It seems really simple. I tried to do a simple find and replace using * as a
wildcard, but it didn't work. All I need to do is get quotation marks before
and after the text in each cell of each row. I know there is a simple
solution out there. Any help would be greatly appreciated.
 
J

Joel

Range("A1") = """" & Range("A1") & """"

You need to have two double quote in a row for it to be displayed as a
double quote

So instead of "a" as a string the a would be replace by two double quotes.

another method is to use chr(34)

Range("A1") = chr(34) & Range("A1") & chr(34)
 
J

jknkboaters

Here is a macro to try. Select the range on your worksheet that needs quoted
text.

Sub TextQuotes()
' Quotes around text
' First select the range to put quotes around
'
Dim c As Range
For Each c In Selection
c = """" & c.Value & """"
Next
End Sub


Sub RemoveTextQuotes()
' Removes quotes around text
' First select the range to remove quoted text
'
Dim c As Range
For Each c In Selection
If Left(c.Value, 1) = """" And Right(c.Value, 1) = """" Then
c.Formula = Mid(c.Value, 2, Len(c.Value) - 2)
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top