CHR is the VBA function and returns the character from the ASCII table.
For example, Chr(34) returns 34th character, which is the “ sign (double quotes).
Look at this example. Let’s say that you want to insert the following name into the cell using the VBA code.
Edwin “Buzz” Aldrin
You can use one of the two methods.
- “Edwin “”Buzz”” Aldrin”
- “Edwin “ & chr(34) & “Buzz” & chr(34) & “ Aldrin“
To illustrate you how you can Execute the following macro inside a cell, use this formula.
ActiveCell.Value = "Edwin " & Chr(34) & "Buzz" & Chr(34) & " Aldrin"
Both examples will display the name in double quotes.
Don’t confuse the chr function with the CHAR function. The first one is used in VBA, the second one in Excel.