How to find/ return a value (VD: trả kết quả nam hoặc nữ)

PHOTO EMBED

Mon Jun 19 2023 10:49:29 GMT+0000 (Coordinated Universal Time)

Saved by @minhhuyen172002 #vba

Sub find_method()
Dim cell As Range
Dim search_range As Range
Application.DisplayAlerts = False
On Error Resume Next
Set search_range = Application.InputBox("Select Your Range of Cells", "Search Range", Type:=8)
On Error GoTo 0
Application.DisplayAlerts = True
If search_range Is Nothing Then
Exit Sub
End If

For Each cell In search_range
Set cell = cell.Find("Mr.")
If Not cell Is Nothing Then
cell.Offset(0, 1).Value = "Male"
End If
Next cell

For Each cell In search_range
Set cell = cell.Find("Ms.")
If Not cell Is Nothing Then
cell.Offset(0, 1).Value = "Female"
End If
Next cell
MsgBox "Done"
End Sub
content_copyCOPY

https://www.exceldemy.com/excel-vba-find-string-in-cell/