Returns the character specified by a number. Converts ASCII/ANSI code numbers to their corresponding characters. Essential for creating special characters, formatting, and character manipulation in Excel.
Master the fundamentals of Excel CHAR function
The CHAR function converts ASCII/ANSI character codes (1-255) to their corresponding characters. It's essential for creating special characters, formatting text with line breaks and tabs, and generating characters that may be difficult to type directly.
Converts numbers 1-255 to characters
Generates characters hard to type
Creates line breaks, tabs, etc.
Useful for formatting and spacing
Function-specific parameters
Function-specific return type
Generate symbols and special characters
Add line breaks and formatting
Replace or identify control characters
Create dynamic text with special formatting
Exact matching required
Returns numeric position
Handles missing text gracefully
=CHAR(number)A number between 1 and 255 specifying which character to return
The character corresponding to the number
Description: Returns the character specified by a number (1-255 for ASCII/ANSI characters)
Convert number to character
ASCII code 65 corresponds to uppercase letter 'A'
Simple VBA implementation of CHAR function
' Basic CHAR in VBA
Range("B1").Value = Application.WorksheetFunction.Char(65)
' Returns: "A"
' Using VBA Chr function (equivalent)
Dim charCode As Integer
charCode = 65
Range("B2").Value = Chr(charCode)
' Returns: "A"
' Create line break in cell
Sub AddLineBreak()
Range("A1").Value = "Hello" & Chr(10) & "World"
Range("A1").WrapText = True
End Sub
' Generate multiple characters
Sub GenerateCharacters()
Dim i As Integer
For i = 65 To 90
Range("A" & (i - 64)).Value = Application.WorksheetFunction.Char(i)
Next i
' Generates A-Z
End Sub
' Create formatted text with tabs
Sub CreateFormattedText()
Range("A1").Value = "Name" & Chr(9) & "Age" & Chr(9) & "City"
End SubGenerate special characters and symbols
' Function to get character from code
Function GetChar(code As Integer) As String
If code >= 1 And code <= 255 Then
GetChar = Chr(code)
Else
GetChar = "#VALUE!"
End If
End Function
' Generate copyright and trademark symbols
Sub SpecialSymbols()
Range("A1").Value = Chr(169) & " Copyright"
Range("A2").Value = Chr(174) & " Registered"
Range("A3").Value = Chr(153) & " Trademark"
End Sub
' Create text with line breaks
Function TextWithBreaks(lines() As String) As String
Dim result As String
Dim i As Integer
result = lines(0)
For i = 1 To UBound(lines)
result = result & Chr(10) & lines(i)
Next i
TextWithBreaks = result
End FunctionGenerate copyright, trademark, and other symbols
Create multi-line text in cells
Add tab spacing in text
Generate letters from codes
CHAR returns #VALUE! when number is out of range
=IF(AND(A1>=1, A1<=255), CHAR(A1), "#VALUE!")Solution: Ensure number is between 1 and 255. Use IF to validate: =IF(AND(number>=1, number<=255), CHAR(number), "#VALUE!")
CHAR(10) line break doesn't show in cell
=CHAR(10)Solution: Enable "Wrap Text" formatting on the cell. Right-click cell > Format Cells > Alignment > Wrap text.
CHAR truncates decimal numbers
=CHAR(ROUND(A1, 0))Solution: CHAR automatically truncates decimals. CHAR(65.7) becomes CHAR(65). Use INT or ROUND if you need specific rounding behavior.
Some CHAR codes produce non-printable characters
=CHAR(7)Solution: Codes 1-31 are control characters (non-printable). Codes 32-126 are printable ASCII. Codes 127-255 are extended characters.