Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default check if sheet exists

how would you go about checking to see if a sheet exists
of not?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default check if sheet exists

One way
(al code in a normal module)

Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function

Use it like this for example

Sub Sheet_Test()
Dim SName As String
If SheetExists("test") = False Then
ActiveSheet.Name = "test"
Else
MsgBox "sorry the sheet exist"
End If
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ross" wrote in message ...
how would you go about checking to see if a sheet exists
of not?



Reply
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
How to check to see if a sheet with a particular name exists? Varun Excel Worksheet Functions 3 January 25th 09 01:41 PM
check if sheet exists mohavv Excel Discussion (Misc queries) 1 November 21st 07 01:58 AM
Check if file exists Jon Excel Discussion (Misc queries) 14 October 4th 07 04:57 PM
check if the sheet/tag exists Alex Excel Worksheet Functions 2 March 14th 06 08:58 PM
check if worksheet exists Craig Wilks Excel Programming 2 July 10th 03 04:07 AM


All times are GMT +1. The time now is 10:09 PM.

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"