- Advanced Excel Functions Tutorial
- Advanced Excel Functions - Home
- Compatibility Functions
- Advanced Excel Functions - Cube
- Database Functions
- Date & Time Functions
- Engineering Functions
- Financial Functions
- Information Functions
- Advanced Excel Functions - Logical
- Lookup & Reference Functions
- Math & Trignometric Functions
- Statistical Functions
- Useful Resources
- Quick Guide
- Useful Resources
- Discussion
Statistical - REPLACE Function
Description
The REPLACE function replaces part of a text string, based on the number of characters you specify, with a different text string.
REPLACEB replaces part of a text string, based on the number of bytes you specify, with a different text string.
REPLACE is intended for use with languages that use the single-byte character set (SBCS), whereas REPLACEB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value as follows −
REPLACE always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
REPLACEB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, REPLACEB counts each character as 1.
The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.
Syntax
REPLACE (old_text, start_num, num_chars, new_text) REPLACEB (old_text, start_num, num_bytes, new_text)
Arguments
Argument | Description | Required/ Optional |
---|---|---|
Old_text | Text in which you want to replace some characters. | Required |
Start_num | The position of the character in old_text that you want to replace with new_text. | Required |
Num_chars | The number of characters in old_text that you want REPLACE to replace with new_text. | Required |
Num_bytes | The number of bytes in old_text that you want REPLACEB to replace with new_text. | Required |
New_text | The text that will replace characters in old_text. | Required |
Notes
If start_num or num_chars is negative or is non-numeric, REPLACE returns #VALUE! error value.
Applicability
Excel 2007, Excel 2010, Excel 2013, Excel 2016