Re: How do I test for the existance of a worksheet?
- From: got.sp4m@xxxxxxxxxxxxxx
- Date: Mon, 2 Feb 2009 23:01:10 -0800 (PST)
Here's an example with the same way of thinking but with a bit simpler
implementation:
Function WsExists(wb As Workbook, strWsName As String) As Boolean
On Error Resume Next
WsExists = Not wb.Worksheets(strWsName) Is Nothing
End Function
best regard
Peder Schmedling
On Feb 3, 2:46 am, "Tim Zych" <feedback at higherdata dt com> wrote:
Create a reusable function...you'll use it again and again..something like:.
Function WksExists(wkb As Workbook, WksName As String) As Boolean
Dim wks As Worksheet
WksExists = False
For Each wks In wkb.Worksheets
If wks.Name = WksName Then
WksExists = True
Exit Function
End If
Next
End Function
If WksExists(ThisWorkbook, "Sheet2") Then
'Code
End If
--
Tim Zychhttp://www.higherdata.com
"John" <J...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FBF56BA5-14A7-4788-9B82-514A6FF24D1E@xxxxxxxxxxxxxxxx
I have the name of a desired worksheet in the variable SheetName.
What form of an If statement do I use to execute some code if this
worksheet
exists?
I appreciate your help, -John
- Follow-Ups:
- Re: How do I test for the existance of a worksheet?
- From: Tim Zych
- Re: How do I test for the existance of a worksheet?
- References:
- How do I test for the existance of a worksheet?
- From: John
- Re: How do I test for the existance of a worksheet?
- From: Tim Zych
- How do I test for the existance of a worksheet?
- Prev by Date: Re: Following yesterday's discussion of Excel 2003 v 2007
- Next by Date: Scroll Bar Position in imbedded Text Box
- Previous by thread: Re: How do I test for the existance of a worksheet?
- Next by thread: Re: How do I test for the existance of a worksheet?
- Index(es):
Relevant Pages
|