View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default If sheet exists, then...

Sorry... There was a typo sheetexits to sheetexists

Sub Test()
if sheetexists("xyz") then
application.displayalerts = false
sheets("xyz").delete
application.displayalerts = true
else
call Macro1
end if
end sub

Public 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

--
HTH...

Jim Thomlinson


"Darin Kramer" wrote:


Hi Jim,

It doesnt like the first sheetexists command....?

Regards

D


*** Sent via Developersdex http://www.developersdex.com ***