LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Determining if a Worksheet Exists

Hi Chaplain Doug,

Chaplain Doug wrote:
Excel 2003. In my VBA code I need to be able to determine if a
particular worksheet exists within a given workbook. For instance,
how do I determine if WbMaster.Worksheets(SheetName) exists without
getting an error if it does not? Thanks for the help.


Error handling is the quickest way to do this, especially if you have lots
of worksheets:

Public Function gbWorksheetExists(rsWorksheetName As String, _
Optional rwbWorkbook As Workbook = Nothing) As Boolean
On Error Resume Next

If rwbWorkbook Is Nothing Then Set rwbWorkbook _
= ActiveWorkbook
gbWorksheetExists = Len(rwbWorkbook.Worksheets( _
rsWorksheetName).Name)
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining if a value already exists in column(s) Rookie_User Excel Discussion (Misc queries) 0 October 3rd 06 05:32 PM
How to check if a worksheet exists in worksheet collection Raghunandan Excel Programming 2 July 19th 04 06:55 AM
Worksheet Exists... James Weaver Excel Programming 3 October 6th 03 02:56 PM
How can I tell if a worksheet exists? Robert Stober Excel Programming 5 October 3rd 03 01:00 AM
Determining if a worksheet exists within a workbook Cory Schneider Excel Programming 1 July 17th 03 12:36 AM


All times are GMT +1. The time now is 05:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"