VBA检查一个sheet是否存在的函数

原创文章,欢迎转载:http://miao.blog/article/vba-sheet-exists

' 检查sheet是否存在
Public Function sheetExists(xBook As Workbook, sheet_name As String) As Boolean
    On Error GoTo ERR_HANDLING

    Dim xSheet As Worksheet
    Set xSheet = xBook.Sheets(sheet_name)
    sheetExists = True

    Exit Function
ERR_HANDLING:
    sheetExists = False
End Function
推荐阅读
VBA发送GET、POST请求的方法
评论