ID EN
#Text

REPLACE

Excel Functions 🇮🇩 Bahasa Indonesia

Ganti teks berdasarkan lokasi

Syntax

EXCEL
=REPLACE(old_text, start_num, num_chars, new_text)

Arguments

Parameter Deskripsi
old_text The text to replace.
start_num The starting location in the text to search.
num_chars The number of characters to replace.
new_text The text to replace old_text with.

Return Value

Teks yang diubah.

Details

Fungsi REPLACE menggantikan teks pada lokasi tertentu di dalam string teks. Lokasi teks yang akan diganti diberikan dalam bentuk angka yang mewakili karakter pertama yang diganti, beserta jumlah karakter untuk menunjukkan berapa banyak karakter yang akan diganti. Berbeda dengan SUBSTITUTE, yang menggantikan teks dengan mencocokkan konten, REPLACE bekerja berdasarkan posisi dan jumlah karakter. REPLACE ideal jika teks yang akan diganti tidak dapat dicocokkan dengan mudah, namun lokasinya dapat diprediksi. Fungsi REPLACE mengambil empat argumen terpisah dalam sintaks umum seperti ini: Argumen pertama, teks_lama, adalah string teks yang akan diproses. Argumen kedua, start_num, menentukan posisi numerik dimana penggantian harus dimulai. Argumen ketiga, num_chars, menunjukkan berapa banyak karakter yang harus diganti. Argumen terakhir

Contoh

Example #1 - Basic usage

REPLACE function takes four separate arguments in a generic syntax like this:

EXCEL
=REPLACE(old_text,start_num,num_chars,new_text)
Example #1 - Basic usage

The first argument, old_text, is the text string to be processed. The second argument, start_num, specifies the numeric position where replacement sho

EXCEL
=REPLACE("C:\docs",1,1,"D") // returns "D:\docs"
=REPLACE("ABC123",4,3,"456") // returns "ABC456"
=REPLACE("XYZ",1,1,"") // returns "YZ"
=REPLACE("www.google.com",1,4,"") // returns "google.com"
Example #2 - Replace different text at same location

In the example below, the goal is to replace the year values in the middle of the text strings in column B with the year 2025. This is a scenario wher

EXCEL
=REPLACE(B5,5,4,"2025")
Example #3 - Change first letter

In the worksheet below, the goal is to change the first letter of each path in column B to the letter "Z". This is another good use case for the REPLA

EXCEL
=REPLACE(B5,1,1,"Z")
Example #4 - Remove first characters

The REPLACE function can be used to remove text by providing an empty string ("") for the new_text argument. In the example below, the goal is to stri

EXCEL
=REPLACE(B5,1,4,"")
Example #5 - Conditionally remove text

In the example below, we have the same problem as above, except the www isn't always present. This means we need to check for the presence of these ch

EXCEL
=IF(LEFT(B5,4)="www.",REPLACE(B5,1,4,""),B5)

See Also

SUBSTITUTE FIND REGEXREPLACE