View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Checking to see if a worksheet exists

"Raman325" wrote in
message ...
What is the best way to check whether a given worksheet exists? For
example, I would like to know whether the "Week 1" worksheet exists
without throwing an error to the user. Thanks in advance for your help.


Here's a function you can use to check for this. It assumes you're
looking for a sheet in the currently active workbook.

Function bSheetExists(ByRef szSheetName As String) As Boolean
On Error Resume Next
bSheetExists = Not (ActiveWorkbook.Sheets(szSheetName) Is Nothing)
End Function

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm