Test or check if sheet exists

后端 未结 22 2553
深忆病人
深忆病人 2020-11-21 23:51
Dim wkbkdestination As Workbook
Dim destsheet As Worksheet

For Each ThisWorkSheet In wkbkorigin.Worksheets 
    \'this throws subscript out of range if there is not         


        
22条回答
  •  别跟我提以往
    2020-11-22 00:13

    Corrected: Without error-handling:

    Function CheckIfSheetExists(SheetName As String) As Boolean
          CheckIfSheetExists = False
          For Each WS In Worksheets
            If SheetName = WS.name Then
              CheckIfSheetExists = True
              Exit Function
            End If
          Next WS
    End Function
    

提交回复
热议问题