Test or check if sheet exists

后端 未结 22 2550
深忆病人
深忆病人 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:26

    If you are specifically interested in worksheets only, you can use a simple Evaluate call:

    Function WorksheetExists(sName As String) As Boolean
        WorksheetExists = Evaluate("ISREF('" & sName & "'!A1)")
    End Function
    

提交回复
热议问题