Test or check if sheet exists

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

    In case anyone wants to avoid VBA and test if a worksheet exists purely within a cell formula, it is possible using the ISREF and INDIRECT functions:

    =ISREF(INDIRECT("SheetName!A1"))

    This will return TRUE if the workbook contains a sheet called SheetName and FALSE otherwise.

提交回复
热议问题