![]() |
Does sheet exist?
What's the proper way to check and see if a specific
sheet exits in the workbook? I need to pull data from this sheet IF it exists...and if it doesn't exist I need to pull data from another sheet I know will be there... If "Multi-Acct Summary" exists then GetDataFromMultiAccount Else GetDataFromSingleAccount End if Thanks!!! |
Does sheet exist?
Sean,
Use a function like Function SheetExists(SheetName As String) As Boolean On Error Resume Next SheetExists = CBool(Len(ThisWorkbook.Worksheets(SheetName).Name) ) End Function Then, you can call this with code like If SheetExists("Sheet1") = True Then ' do something Else ' do something else End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Sean Evanovich" wrote in message ... What's the proper way to check and see if a specific sheet exits in the workbook? I need to pull data from this sheet IF it exists...and if it doesn't exist I need to pull data from another sheet I know will be there... If "Multi-Acct Summary" exists then GetDataFromMultiAccount Else GetDataFromSingleAccount End if Thanks!!! |
Does sheet exist?
Try this. If sheet 22 does not exist it gets info from sheet 2.
Sub getifthere() On Error Resume Next MsgBox Sheets("Sheet22").Range("c5") MsgBox Sheets("Sheet2").Range("c5") End Sub -- Don Guillett SalesAid Software "Sean Evanovich" wrote in message ... What's the proper way to check and see if a specific sheet exits in the workbook? I need to pull data from this sheet IF it exists...and if it doesn't exist I need to pull data from another sheet I know will be there... If "Multi-Acct Summary" exists then GetDataFromMultiAccount Else GetDataFromSingleAccount End if Thanks!!! |
All times are GMT +1. The time now is 09:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com