ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to give escape sequence in Excel string literals... (https://www.excelbanter.com/excel-programming/336677-how-give-escape-sequence-excel-string-literals.html)

[email protected]

How to give escape sequence in Excel string literals...
 
Hi,

I found that Excel does not allow C-lang style escape sequence. E.g. \"
like escape is not allowed. I tried with other tinkering as well but
did not work. Could not found direct pointer from Excel help.

Can somebody help, how to put escape sequences in Excel functions?

Thanks for your time.

- KA


Tom Ogilvy

How to give escape sequence in Excel string literals...
 
you can use chr(34) and concatenate it. (or produce any character using chr)

In line for double quotes, you double the double quote

sStr = "this is ""Jim's"" last chance"


from the immediate window:
sStr = "this is ""Jim's"" last chance"
? sStr
this is "Jim's" last chance


\n would be the constant vbNewLine

"this is placed" & vbNewLine & "on two lines"

but as you see, you need to use concatenation.

? "this is placed" & vbNewLine & "on two lines"
this is placed
on two lines

--
Regards,
Tom Ogilvy



wrote in message
oups.com...
Hi,

I found that Excel does not allow C-lang style escape sequence. E.g. \"
like escape is not allowed. I tried with other tinkering as well but
did not work. Could not found direct pointer from Excel help.

Can somebody help, how to put escape sequences in Excel functions?

Thanks for your time.

- KA




[email protected]

How to give escape sequence in Excel string literals...
 
Thanks Tom, it worked.
Thanks for your time and solution.
Regards.
- Kedar Agarkar

Tom Ogilvy wrote:
you can use chr(34) and concatenate it. (or produce any character using chr)

In line for double quotes, you double the double quote

sStr = "this is ""Jim's"" last chance"


from the immediate window:
sStr = "this is ""Jim's"" last chance"
? sStr
this is "Jim's" last chance


\n would be the constant vbNewLine

"this is placed" & vbNewLine & "on two lines"

but as you see, you need to use concatenation.

? "this is placed" & vbNewLine & "on two lines"
this is placed
on two lines

--
Regards,
Tom Ogilvy



wrote in message
oups.com...
Hi,

I found that Excel does not allow C-lang style escape sequence. E.g. \"
like escape is not allowed. I tried with other tinkering as well but
did not work. Could not found direct pointer from Excel help.

Can somebody help, how to put escape sequences in Excel functions?

Thanks for your time.

- KA




All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com