Share Bài 150: Hàm Substitute và Replace trong Excel

thanhhau891

New member
#Excel #Replace #Substologen #Studying #Office ** Cách sử dụng thay thế và thay thế các chức năng trong Excel **

** Chức năng thay thế **

Hàm thay thế trong Excel được sử dụng để thay thế một văn bản cụ thể bằng một văn bản khác trong một ô hoặc phạm vi ô.

Cú pháp của hàm thay thế là:

`` `
= thay thế (văn bản, old_text, new_text, instance_num)
`` `

Ở đâu:

* `Text` là văn bản mà bạn muốn tìm kiếm.
* `old_text` là văn bản mà bạn muốn thay thế.
* `new_text` là văn bản mà bạn muốn thay thế` old_text` bằng.
* `instance_num` là số lượng phiên bản của` old_text` mà bạn muốn thay thế.Nếu bạn bỏ qua tham số này, tất cả các trường hợp của `old_text` sẽ được thay thế.

Ví dụ: công thức sau sẽ thay thế tất cả các trường hợp của văn bản "2013" bằng văn bản "2016" trong ô A1:

`` `
= Thay thế (A1, "2013", "2016")
`` `

** Thay thế chức năng **

Hàm thay thế trong Excel tương tự như hàm thay thế, nhưng nó cho phép bạn chỉ định vị trí bắt đầu và số lượng ký tự để thay thế.

Cú pháp của hàm thay thế là:

`` `
= thay thế (văn bản, start_num, num_chars, new_text)
`` `

Ở đâu:

* `Text` là văn bản mà bạn muốn tìm kiếm.
* `start_num` là vị trí bắt đầu của văn bản mà bạn muốn thay thế.
* `num_chars` là số lượng ký tự bạn muốn thay thế.
* `new_text` là văn bản mà bạn muốn thay thế các ký tự đã chọn bằng.

Ví dụ: công thức sau sẽ thay thế hai ký tự đầu tiên của văn bản "Hello World" bằng văn bản "Hi":

`` `
= Thay thế ("Hello World", "12", "Hi")
`` `

** Tìm và thay thế hộp thoại **

Bạn cũng có thể sử dụng hộp thoại Tìm và thay thế để nhanh chóng tìm và thay thế văn bản trong Excel.

Để mở hộp thoại Tìm và thay thế, nhấp vào tab Home và sau đó nhấp vào nút Tìm & Chọn.

Trong hộp thoại Tìm và thay thế, bạn có thể nhập văn bản mà bạn muốn tìm trong hộp tìm gì và văn bản mà bạn muốn thay thế nó trong hộp thay thế.

Bạn cũng có thể sử dụng các tùy chọn sau để điều chỉnh tìm kiếm của mình:

*** Trường hợp khớp: ** Tùy chọn này sẽ khớp với trường hợp của văn bản mà bạn đang tìm kiếm.
*** Chỉ toàn bộ từ: ** Tùy chọn này sẽ chỉ khớp với toàn bộ từ.
*** Sử dụng Wildcards: ** Tùy chọn này sẽ cho phép bạn sử dụng ký tự đại diện khi tìm kiếm văn bản.

Khi bạn đã nhập các tiêu chí tìm kiếm mong muốn, nhấp vào nút Tìm tất cả để tìm tất cả các trường hợp của văn bản mà bạn đang tìm kiếm.

Để thay thế tất cả các phiên bản của văn bản mà bạn đang tìm kiếm, nhấp vào nút Thay thế tất cả.

**Ví dụ**

Ví dụ sau đây cho thấy cách sử dụng hộp thoại Tìm và thay thế để thay thế tất cả các phiên bản của văn bản "TX" bằng văn bản "CA" trong phạm vi A1: A10:

1. Chọn phạm vi A1: A10.
2. Trên tab Trang chủ, trong nhóm chỉnh sửa, nhấp vào Tìm & Chọn.
3. Nhấp vào Thay thế.
4. Nhập văn bản bạn muốn tìm (TX) vào hộp tìm kiếm.
5. Nhập văn bản bạn muốn thay thế nó bằng (CA) vào hộp thay thế.
6. Nhấp vào 'Thay thế tất cả'.

Bảng sau đây cho thấy kết quả của hoạt động tìm và thay thế:

|A1 |A2 |A3 |A4 |A5 |A6 |A7 |A8 |A9 |A10 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
|Tx |1 |2 |3 |4 |5 |6 |7 |8 |9 |
|Ca |1 |2 |3 |4 |
=======================================
#Excel #Replace #Substitute #Studying #Office **How to use substitute and replace functions in Excel**

**Substitute function**

The substitute function in Excel is used to replace a specific text with another text in a cell or range of cells.

The syntax of the substitute function is:

```
=substitute(text,old_text,new_text,instance_num)
```

Where:

* `text` is the text that you want to search for.
* `old_text` is the text that you want to replace.
* `new_text` is the text that you want to replace `old_text` with.
* `instance_num` is the number of instances of `old_text` that you want to replace. If you omit this parameter, all instances of `old_text` will be replaced.

For example, the following formula will replace all instances of the text "2013" with the text "2016" in the cell A1:

```
=substitute(A1,"2013","2016")
```

**Replace function**

The replace function in Excel is similar to the substitute function, but it allows you to specify the starting position and number of characters to replace.

The syntax of the replace function is:

```
=replace(text,start_num,num_chars,new_text)
```

Where:

* `text` is the text that you want to search for.
* `start_num` is the starting position of the text that you want to replace.
* `num_chars` is the number of characters that you want to replace.
* `new_text` is the text that you want to replace the selected characters with.

For example, the following formula will replace the first two characters of the text "Hello World" with the text "Hi":

```
=replace("Hello World","12","Hi")
```

**Find and Replace dialog box**

You can also use the Find and Replace dialog box to quickly find and replace text in Excel.

To open the Find and Replace dialog box, click on the Home tab and then click on the Find & Select button.

In the Find and Replace dialog box, you can enter the text that you want to find in the Find what box and the text that you want to replace it with in the Replace with box.

You can also use the following options to fine-tune your search:

* **Match case:** This option will match the case of the text that you are searching for.
* **Whole words only:** This option will only match whole words.
* **Use wildcards:** This option will allow you to use wildcards when searching for text.

Once you have entered the desired search criteria, click on the Find All button to find all instances of the text that you are searching for.

To replace all instances of the text that you are searching for, click on the Replace All button.

**Example**

The following example shows how to use the Find and Replace dialog box to replace all instances of the text "TX" with the text "CA" in the range A1:A10:

1. Select the range A1:A10.
2. On the Home tab, in the editing group, click Find & Select.
3. Click Replace.
4. Enter the text you want to find (TX) in the Find what box.
5. Enter the text you want to replace it with (CA) in the Replace with box.
6. Click 'Replace All'.

The following table shows the results of the Find and Replace operation:

| A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 |
|---|---|---|---|---|---|---|---|---|---|
| TX | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| CA | 1 | 2 | 3 | 4 |
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top