» Determine if a sheet exists in a workbook using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Files, Workbook, and Worksheets in VBA
VERSION - All Microsoft Excel Versions
Function SheetExists(SheetName As String) As Boolean
' returns TRUE if the sheet exists in the active workbook
SheetExists = False
On Error GoTo NoSuchSheet
If Len(Sheets(SheetName).Name) > 0 Then
SheetExists = True
Exit Function
End If
NoSuchSheet:
End Function
Example:
If Not SheetExists("MySheetName") Then
MsgBox "MySheetName doesn't exist!"
Else
Sheets("MySheetName").Activate
End If
Book Store:
Recommended Books:
- Financial Statement Analysis with S&P insert card
- Managing by the Numbers: A Commonsense Guide to Understanding and Using Your Company's Financials: An Essential Resource for Growing Businesses
- Microsoft Excel 2002 Formulas (With CD-ROM)
- Fish! A Remarkable Way to Boost Morale and Improve Results
- Microsoft Office XP Introductory Concepts and Techniques
No comments have been submitted.


