工作表是否存在

  1. Function ExistSheet(sheetName As String) As Boolean
  2. Dim sh As Worksheet
  3. On Error GoTo Err_Handle
  4. Set sh = Worksheets(sheetName)
  5. ExistSheet = IIf(sh Is Nothing, False, True)
  6. Set sh = Nothing
  7. Exit Function
  8. Err_Handle:
  9. ExistSheet = False
  10. End Function