Home / Functions / Is Workbook Open Function

Is Workbook Open Function

The following Function has been designed to check if a workbook you are about to open is already open. If it is then it will return TRUE, if not then the Function will return FALSE and your other Macro code should then open the workbook that is required.

Function IsWorkbookOpen(wbName As String) As Boolean
'Will verify if a Workbook is open before trying to open it
Dim wb As Workbook
    IsWorkbookOpen = True
    On Error Resume Next
    Set wb = Workbooks(wbName)
    If wb Is Nothing Then IsWorkbookOpen = False
End Function

If you have a question on this post for the Excel Help Desk team or have something you would like to share on this topic then please leave a comment.

About Excel Help Desk

Check Also

Calculate Number of Days in another Date Range

A custom function has been developed to calculate the Number of Days that one Date Range is within another. This can be very useful when calculating the overlapping periods.