Sub Tim_Sheet()
Dim IsFound As Boolean
Dim i As Integer, Sosheet As Long
Dim TenSheet As String
Sosheet = ActiveWorkbook.Sheets.Count
TenSheet = LCase(Application.InputBox("Ban go ten cua Sheet:", "GPE"))
If TenSheet = "false" Then Exit Sub 'Neu nguoi dung nhan Cancel thi khong tim
If TenSheet = "" Then 'Truong hop nguoi dung khong vao gia tri
MsgBox "Ban hay dua ten sheet de tim.", vbExclamation, "Thieu du lieu tim"
Exit Sub
End If
IsFound = False
For i = 1 To Sosheet
If InStr(1, LCase(Sheets(i).Name), TenSheet) > 0 Then
IsFound = True
Sheets(i).Select
If MsgBox("Da tim duoc sheet chua ten """ & TenSheet & """ . Ban co muon tim tiep khong?", vbYesNo + vbQuestion, "Tim sheet") = vbNo Then
Exit For
End If
End If
Next
'Neu khong tim duoc
If Not IsFound Then MsgBox "Khong tim thay sheet co ten """ & TenSheet & """.", vbExclamation, "Khong tim thay ten sheet"
End Sub