View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dnereb[_14_] Dnereb[_14_] is offline
external usenet poster
 
Posts: 1
Default Checking to see if a worksheet exists


use error supression like this:


Code
-------------------
Function IsWorksheetPresent(Name As String) As Boolean

Dim Ws As Worksheet

On Error Resume Next

For Each Wb In ThisWorkbook.Worksheets
Err.Clear
If UCase(Ws.Name) = Name Then
On Error GoTo 0
IsWorksheetPresent = True
Exit Function
End If
Next
On Error GoTo 0
End Functio
-------------------


this will return a True if the worksheet is present
you could use it like this:


Code
-------------------
if IsWorksheetPresent("Week 1") then
'Do your Stuff
end i
-------------------

--
Dnere
-----------------------------------------------------------------------
Dnereb's Profile: http://www.excelforum.com/member.php...fo&userid=2618
View this thread: http://www.excelforum.com/showthread.php?threadid=39725