CHAR

Text Functions
(4.7/5)

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.

Interactive Formula Tester

=CHAR("65")

Complete Theory & Understanding

Master the fundamentals of Excel CHAR function

Core Concept

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.

Why Use CHAR?

  • Generate symbols and special characters
  • Add line breaks and formatting
  • Replace or identify control characters
  • Create dynamic text with special formatting

Key Characteristics

ASCII/ANSI Codes

Converts numbers 1-255 to characters

CHAR(65) returns "A"

Special Characters

Generates characters hard to type

CHAR(169) returns "©"

Control Characters

Creates line breaks, tabs, etc.

CHAR(10) for line feed

Text Formatting

Useful for formatting and spacing

CHAR(9) for tab spacing

Function Anatomy

=CHAR(parameters...)
Required
Parameters:

Function-specific parameters

Returns
Return Value:

Function-specific return type

Primary Use Cases

Special Characters

Generate symbols and special characters

Text Formatting

Add line breaks and formatting

Data Cleaning

Replace or identify control characters

Dynamic Text

Create dynamic text with special formatting

Theory Summary

Precise

Exact matching required

Position-Based

Returns numeric position

Error-Safe

Handles missing text gracefully

Syntax & Parameters

=CHAR(number)
Required
number:

A number between 1 and 255 specifying which character to return

Returns
Return Value:

The character corresponding to the number

Description: Returns the character specified by a number (1-255 for ASCII/ANSI characters)

Interactive Examples

Basic Character Conversion

Convert number to character

"65"
=CHAR(65)
A

ASCII code 65 corresponds to uppercase letter 'A'

VBA Implementation & Automation

Basic CHAR in VBA

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 Sub

Advanced Character Generation

Generate 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 Function

Business Applications

Special Characters

Generate copyright, trademark, and other symbols

=CHAR(169) & " Copyright"

Line Breaks

Create multi-line text in cells

="Line 1" & CHAR(10) & "Line 2"

Tab Formatting

Add tab spacing in text

="Name" & CHAR(9) & "Value"

Alphabet Generation

Generate letters from codes

=CHAR(ROW()+64)

Common Issues & Solutions

#VALUE! Error

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!")

Line Break Not Visible

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.

Decimal Numbers

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.

Control Characters

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.

Performance Tips & Best Practices

⚡ Performance Optimization

  • Use CHAR efficiently for special characters
  • Cache CHAR results when used repeatedly
  • Consider using Unicode functions (UNICHAR) for extended character sets
  • Validate number range before using CHAR

🎯 Best Practices

  • Use CHAR(10) for line breaks (enable Wrap Text)
  • Use CHAR(9) for tab spacing
  • Remember CHAR uses ASCII/ANSI codes (1-255)
  • Document CHAR usage for special character codes

💡 Pro Tips

  • CHAR(65-90) generates A-Z, CHAR(97-122) generates a-z
  • CHAR(169) = ©, CHAR(174) = ®, CHAR(153) = ™
  • CHAR(10) requires Wrap Text to display line break
  • Use CODE function to find character codes