ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   check to see if sheet exists (https://www.excelbanter.com/excel-programming/311760-check-see-if-sheet-exists.html)

Wandering Mage

check to see if sheet exists
 
Is there anyway to see if a sheet of a given name exists.
I want to write and if statement:
if Sheet("rev date") *does exist* Then
true condition
Else
false condition
End If

I there a way to do this?

Bob Phillips[_6_]

check to see if sheet exists
 
Here's a function

'-----------------------------------------------------------------
Function SheetExists(Sh As String, _
Optional wb As Workbook) As Boolean
'-----------------------------------------------------------------
Dim oWs As Worksheet
If wb Is Nothing Then Set wb = ActiveWorkbook
On Error Resume Next
SheetExists = CBool(Not wb.Worksheets(Sh) Is Nothing)
On Error GoTo 0
End Function


--

HTH

RP

"Wandering Mage" wrote in message
...
Is there anyway to see if a sheet of a given name exists.
I want to write and if statement:
if Sheet("rev date") *does exist* Then
true condition
Else
false condition
End If

I there a way to do this?





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com