VBA & Macro Problems

How to Find and Replace Unicode Characters Using VBA in Excel

Steve KSteve K Nov 3, 2026 869 views

Question details

The user needs to find and replace special Unicode characters (like ș, Ș, ț, Ț) using VBA without them turning into question marks in the code editor.

How to Find and Replace Unicode Characters Using VBA in Excel
Product
Excel
Device & OS
not provided
Scenario
Writing VBA macros to automate text manipulation containing special or international Unicode characters.
Observed behavior
Entering special Unicode characters directly into the VBA editor results in them displaying as question marks due to the editor's encoding limitations.
Before you start

Ensure you have the exact decimal Unicode code points for the special characters you wish to insert, and verify that the font used in your worksheet supports these specific characters.

Solution 1Recommended

Use the VBA ChrW Function to Output Unicode Characters

Use the ChrW function paired with the character's decimal Unicode value to reliably output special characters via VBA and prevent them from degrading into question marks.

The standard VBA editor does not natively support full Unicode text input. As a result, pasting or typing special characters directly into the code window often converts them to question marks. The ChrW function bypasses this limitation by generating the character directly from its code point during the macro's execution.

1
Identify the Unicode code point

Determine the decimal Unicode value for your character. For example, the code point for Ș is 536, ș is 537, Ț is 538, and ț is 539.

2
Open the VBA Editor

Press Alt + F11 to launch the Visual Basic for Applications editor, and insert a new module from the 'Insert' menu.

3
Write the Replace command for a single cell

Use the Replace function combined with ChrW in your code. For instance, to update the active cell, use: ActiveCell.Value = Replace("Stefan", "S", ChrW(536))

4
Apply the replacement to a worksheet range

To apply this to an entire range, utilize the Range object's Replace method: Range("A1:A50").Replace What:="Stefan", Replacement:=ChrW(536) & "tefan"

5
Run the macro

Press F5 or click the Run button to execute the code. Check your worksheet to ensure the special characters display correctly.

Use the VBA ChrW Function to Output Unicode Characters
Font Compatibility: Always use a Unicode-compliant font like Calibri, Arial, or Times New Roman in your worksheet to prevent the newly inserted characters from appearing as blank squares.
Powerful Spreadsheet Alternative

Run Macros and VBA Seamlessly with WPS Office

WPS Office provides robust support for VBA and macros, allowing you to seamlessly run your existing Excel scripts to automate tasks and manipulate Unicode characters without any hassle.

  1. 1. Download and install WPS Office: Get the free WPS Office suite from the official website and install it on your device.
  2. 2. Open your macro-enabled spreadsheet: Launch WPS Spreadsheet and open your .xlsm file containing the data you want to modify.
  3. 3. Access the VBA editor: Navigate to the 'Developer' tab on the ribbon and click 'Visual Basic' to open the code editor.
  4. 4. Run your ChrW script: Paste your ChrW replacement script into the module and click Run to automatically update the special characters in your spreadsheet.
Fully compatible with Microsoft Excel (.xlsx, .xlsm, .xls) formats.Built-in VBA editor to easily create, edit, and run macros for Unicode manipulation.Free and lightweight office suite covering documents, spreadsheets, and presentations.Seamless migration of your existing VBA scripts with zero learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why do my special characters show up as question marks in the VBA editor?

The standard VBA IDE (Integrated Development Environment) uses ANSI encoding rather than UTF-8 or full Unicode. When you paste or type characters that fall outside the standard ANSI range, the editor cannot recognize them and defaults to displaying question marks.

How do I find the correct Unicode decimal value for a specific character?

You can easily find a character's decimal value by using the UNICODE() function directly in an Excel cell (e.g., typing =UNICODE("Ș")). You can then take the resulting number and use it inside the ChrW() function in your VBA code.

What is the difference between the Chr and ChrW functions in VBA?

The Chr function returns a character based on the system's default ANSI character set, which is limited to a small range of basic characters. The ChrW function, on the other hand, returns a Unicode character, allowing you to access thousands of international and special symbols.

Why are my replaced characters showing up as square boxes in the worksheet?

If your VBA macro ran successfully but you see square boxes instead of the expected letters, the font currently applied to those specific cells does not contain the glyphs for those Unicode characters. Change the cell font to a widely supported one like Arial, Calibri, or Segoe UI.