In this article, I am going to explain you, how can you use special characters in Excel VBA and formulas without breaking the syntax.
For Example: You can not use double quote or any other Special Characters, which are generally a part of Formula Syntax, directly in a cell while using formula because using them, will spoil the syntax of the formula and it will through an error. To overcome this issue, one can use the ASCII number of those characters. ASCII values can be used to refer the characters in both Excel formulas as well as Excel VBA.
Use of ASCII numbers in Excel Formulas as well as Excel VBA programming
CHAR( ASCII Number)
VBA.Chr( ASCII Number)
Here is the list of ASCII keys of few most used symbols which may affect the formula syntax in Excel if they are used as it is:
|Symbol||ASCII Code||Syntax – Excel Formula||Syntax – Excel VBA|
|$ – Dollar Sign||36||=Char(36)||VBA.Chr(36)|
|” – Double Quote||34||=Char(34)||VBA.Chr(34)|
|& – Ampersand Sign||38||=Char(38)||VBA.Chr(38)|
|( – Opening Braces||40||=Char(40)||VBA.Chr(40)|
|) – Closing Braces||41||=Char(41)||VBA.Chr(41)|
|@ – At the rate Sign||64||=Char(64)||VBA.Chr(64)|