Option Explicit
Private Sub Cmdsearch_Click()
Dim Search As String, sRng As Range
Search = TextBox1.Text
If Search = "" Then
MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE"
Exit Sub
Else
Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If sRng Is Nothing Then
MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE"
Else
MsgBox sRng.Address
End If
End If
End Sub
PHP:Option Explicit Private Sub Cmdsearch_Click() Dim Search As String, sRng As Range Search = TextBox1.Text If Search = "" Then MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE" Exit Sub Else Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If sRng Is Nothing Then MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE" Else MsgBox sRng.Address End If End If End Sub
Sửa lại như sauVoi doan code nay, minh muon nhay xuong toi dong minh vua tim co duoc ko
Private Sub Cmdsearch_Click()
Dim Search As String, sRng As Range
Search = TextBox1.Text
If Search = "" Then
MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE"
Exit Sub
Else
Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If sRng Is Nothing Then
MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE"
Else
Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
End If
End If
End Sub