Option Explicit
Sub tim_sheet()
Dim sheetname As String
Dim ws As Object
sheetname = InputBox(" Nhap ten sheet can chep", "Kiem tra sheet")
For Each ws In ThisWorkbook.Sheets
If ws.Name = sheetname Then
MsgBox ("Sheet " & sheetname & " ton tai")
Exit Sub
End If
Next
MsgBox ("Sheet " & sheetname & " khong ton tai")
End Sub
Không thì bạn dùng cái này cho đơn giản hơn
Option Explicit
Public Function WsExit(wsName As String) As Boolean
On Error Resume Next
WsExit = CBool(Len(Worksheets(wsName).Name) > 0)
End Function
Hàm trả về giá trị True / False