Türk | İngilizce |
---|---|
DEĞİŞTİR, DEĞİŞTİRB | REPLACE, REPLACEBs |
In Microsoft Excel and Google Sheets, there are highly useful functions designed for replacing a specific segment of text within a string with alternative text. These functions are particularly valuable during data editing and cleansing tasks. This article will thoroughly explore the usage of the “REPLACE” and “REPLACEB” functions in Excel and Google Sheets.
Using REPLACE and REPLACEB Functions
The REPLACE and REPLACEB functions are used to substitute a certain number of characters starting from a specified position within a text string. REPLACE operates based on the number of characters, while REPLACEB modifies text based on byte count, which is crucial for languages that use Double Byte Character Set (DBCS).
Syntax:
REPLACE(old_text, start_num, num_chars, new_text) REPLACEB(old_text, start_num, num_bytes, new_text)
- old_text: The original text that will be modified.
- start_num: The position within old_text where the replacement will start. Positions begin at 1.
- num_chars / num_bytes: The amount of characters/bytes to be replaced.
- new_text: The text that will replace the specified segment in the original text.
Example Usage:
=REPLACE("Hello World", 7, 5, "Turkey")
In this example, the phrase “Hello World” will have 5 characters starting from the 7th character (“World”) replaced with “Turkey”, resulting in “Hello Turkey”.
Practical Applications
Updating Personal Information
In scenarios where names in a personal information form need to be updated, you may want to remove middle names. Assume a column contains full names and you wish to remove the middle names:
=REPLACE(A1, FIND(" ", A1), FIND(" ", A1, FIND(" ", A1) + 1) - FIND(" ", A1), "")
This formula takes the name in cell A1, finds the segment from the first to the second space, and removes it. For example, it modifies “John Michael Doe” to “John Doe”.
Modifying Number Formats
When you need to convert a specific phone number format to another, the REPLACE function can be handy. For instance, transforming a phone number from “(123) 456-7890” format to “123-456-7890”:
=REPLACE(A2, 1, 1, "")
This simple change removes the opening parenthesis at the start of the number. More modifications can be achieved by chaining functions together.
These basic details about Excel and Google Sheets” REPLACE and REPLACEB functions can significantly simplify your text processing needs. As illustrated, they are immensely helpful for text editing and formatting tasks.