Home > Uncategorized > Isworksheetopen and Isworkbookopen functions

Isworksheetopen and Isworkbookopen functions

February 23rd, 2005 Leave a comment Go to comments

Here’s a IsWorkbookOpen function to check if a workbook is open or not. Returns TRUE or FALSE

Public Function IsWorkbookOpen(ByVal wkbkname As String) As Boolean
Dim Wb As Workbook
‘check if its already opened in the Windows collection
For Each Wb In Workbooks
If Wb.Name = wkbkname Then IsWorkbookOpen = True
GoTo exitsub
End If
Next Wb
exitsub:
End Sub

Here’s a IsWorksheetOpen function to check if a worksheet is open or not. Returns TRUE or FALSE

Public Function IsWorksheetOpen(ByVal wsname As String) As Boolean
Dim wk As Worksheet
For Each wk In Worksheets
If wk.Name = wsname Then
IsWorksheetOpen = True
GoTo exitsub
End If
Next wk
exitsub:
End Function
Categories: Uncategorized Tags: , ,
  1. Antho765432
    May 31st, 2009 at 16:13 | #1

    that worked

  1. No trackbacks yet.