View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Thierry Paradis Thierry Paradis is offline
external usenet poster
 
Posts: 8
Default How to check from VBA if sheet exists?

Here's the code:

Public Sub VérifierFeuille(ByVal strValeur As String)
Dim wSheet As Worksheet

On Error Resume Next
Set wSheet = ActiveWorkbook.Sheets(strValeur)
If wSheet Is Nothing Then
MsgBox "The sheet" + strValeur + " is not present, the application
will be stop.", vbCritical + vbOKOnly, "Error"
End
Else
Set wSheet = Nothing
End If
End Sub


"Alen" a écrit dans le message de news:
...
How to check from VBA if sheet named "JohnDoe" exists in workbook?

Sub del_sheet()

if exist(sheets("JohnDoe")) then
application.displayalerts = false
sheets("JohnDoe").delete
application.displayalerts = true
end if

With what code I have to put instead of "exist(sheets("JohnDoe"))"

Regards, Alen