Workbook Exists

Function WorkbookExists(sWbName As String) As Boolean
'Returns True if workbook is open

Dim oWb As Workbook

On Error Resume Next
Set oWb = Workbooks(sWbName)
WorkbookExists = Not CBool(Err.Number)
On Error GoTo 0
End Function

2 thoughts on “Workbook Exists

  1. Dick,

    Although this is less readable, it’s faster and a bit shorter:

  2. Or faster yet:

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.