Learn Excel - Simplify Life with Excel Concepts

Excel CHR Function (VBA)

CHR Function VBA Code

How to use the CHR Function (VBA)

This Excel tutorial explains how to use the Excel CHR function with syntax and examples using VBA.

SUMMARY:

The Excel VBA CHR function returns the character of a supplied character code numeric value between 0 and 255.

For example,

  • The VBA Code Chr(78) would return "N".
  • The VBA Code Chr(112) would return "p".

PURPOSE:

To convert an Character Code to Characters.

RETURN VALUE:

Returns a String value.

SYNTAX:

Chr(charcode)

ARGUMENTS:

The Chr function syntax has the following arguments:

  • charcode: Required. The number(charcode) between 1 and 255.
    • Any number between 1 to 255.

REMARKS:

  • The Chr function can only be used in VBA code in Microsoft Excel.
  • The range for charcode is a number between 1 and 255.
  • This function will convert charcode (numerical value) into character value.
  • If the expression passed to the function is not into the specified number range, an error occurs.

Useful Links: Link 1Link 2Link 3