View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Checking if Sheet Exists?

Sub gsnu()
Dim w As Worksheet
For Each w In Worksheets
If w.Name = "trial" Then
MsgBox ("worksheet " & w.Name & " already exists")
Exit Sub
End If
Next
MsgBox ("worksheet " & "trial" & " does not exist")
End Sub

--
Gary''s Student


" wrote:

Hi,

Is there a way in Visual basic to check if a worksheet with a specific
name exists? If it does not exist, I want to add it and format it; if
it does, I just want to format it.

Thanks!

Brett