两种方案
1,第一种,当参数是workbook时
Function WorksheetExists(wb As Workbook, sName As String) As Boolean
Dim s As String
On Error GoTo ErrHandle
s = wb.Worksheets(sName).Name
WorksheetExists = True
Exit Function
ErrHandle:
WorksheetExists = False
End Function
或者当第一个参数是文件名的时候
Function WorksheetExists(wb As String, sName As String) As Boolean
Dim s As String
On Error GoTo ErrHandle
Windows(GetNoPathFile(wb)).Activate
ActiveWorkbook.Sheets(sName).Select
WorksheetExists = True
Exit Function
ErrHandle:
WorksheetExists = False
End Function