ID EN
#Text

SUBSTITUTE

Excel Functions 🇮🇩 Bahasa Indonesia

Ganti teks berdasarkan konten

Syntax

EXCEL
=SUBSTITUTE(text, old_text, new_text, [instance_num])

Arguments

Parameter Deskripsi
text The text to change.
old_text The text to replace.
new_text The text to replace with.
instance_num [optional] The instance to replace. If not supplied, all instances are replaced.

Return Value

Teks yang diproses

Details

Fungsi SUBSTITUTE adalah cara untuk melakukan pencarian dan penggantian dengan rumus. Gunakan ketika Anda tahu teks apa yang ingin Anda ubah, tetapi Anda tidak tahu (atau peduli) di mana teks itu muncul dalam string teks. Secara default, SUBSTITUTE akan mengganti semua contoh string teks dengan string teks lain. Secara opsional, Anda dapat menentukan contoh teks mana yang akan diganti dengan memberikan nomor. Untuk menghapus sepenuhnya teks yang cocok (teks_lama), masukkan string kosong ("") untuk argumen teks_baru. Fungsi SUBSTITUTE digunakan untuk mengganti satu string teks dengan yang lain menggunakan sintaks umum seperti ini: Dimana teks adalah nilai yang akan diproses (biasanya referensi sel), teks_lama adalah teks yang akan ditemukan, teks_baru adalah teks yang akan diganti, dan jumlah_instance adalah argumen opsional untuk menargetkan hanya contoh tertentu dari teks_lama b

Contoh

Example #1 - Basic usage

The SUBSTITUTE function is used to replace one text string with another using a generic syntax like this:

EXCEL
=SUBSTITUTE(text,old_text,new_text,[instance_num])
Example #1 - Basic usage

Where text is the value to process (typically a cell reference), old_text is the text to find, new_text is the text to replace with, and instance_num

EXCEL
=SUBSTITUTE(B5,"t","b") // replace all t's with b's
=SUBSTITUTE(B6,"t","b",1) // replace first t with b
=SUBSTITUTE(B7,"t","b") // replace all t's with b's
=SUBSTITUTE(B8,"cat","dog") // replace cat with dog
=SUBSTITUTE(B9,"#","") // replace # with nothing
=SUBSTITUTE(B10,"-",", ") // replace hyphens with commas
Example #2 - Replace all

By default, the SUBSTITUTE function will replace all instances of one text string with another. You can see this behavior in the worksheet below, wher

EXCEL
=SUBSTITUTE(B5,".","-")
Example #3 - Replace nth instance

By default, SUBSTITUTE will replace all instances of one text string with another. The optional fourth argument, called instance_num, can be used to r

EXCEL
=SUBSTITUTE(B5," ","-",2)
Example #4 - Replace line breaks

SUBSTITUTE can be combined with other functions to solve more difficult problems. The example below uses the SUBSTITUTE function to replace line break

EXCEL
=SUBSTITUTE(B5,CHAR(10),", ")
Example #5 - Remove unwanted text

You can use the SUBSTITUTE function to completely remove unwanted text by providing an empty string for the new_text argument. You can see this approa

EXCEL
=SUBSTITUTE(B5:B16,"*","")+0

See Also

REPLACE REGEXREPLACE