Escape for special characters in string

  • Thread starter Thread starter Jag Man
  • Start date Start date
J

Jag Man

I want to be able to put:

.InsertLines StartLine, " sheetName = ActiveSheet.name & "sheetName""

to generate the code section of a button click procedure. The problem is the
embeded
double quote. In C/C++ one would write the embedded double quote as \",
i.e., the
\ "escapes" the string interpretation to treat the followin character
literally.

Is there such a concept in VBA? I've tried putting Chr(42) but this does not
generate the wanted
code.

Ed
 
The escape character is actually the doublequote itself "

As an example:
msgbox """"
Would display just the one doublequote.

Rob
 
Jag Man,

In VBA
Chr(34)
would be your quote symbol.

To enclose a quote in VBA you have to enclose it in quotes.
e.g.
"""
would give you a quote mark.

As an example:

Range("A1").Formula="=IF(D1=""Y"",1,2)"
Excel would write that formula into Cell A1 as:
=IF(D1="Y",1,2)

John
 
Back
Top