Check for dated sheet

M

Mike K

Oh great ones,
I have a recorded macro which works fine when opened
the first time. How would I add a check for exsistance of
this specific sheet name to avoid the error you get when
you re-open the workbook? It will ultimately be a workbook
open event.

Excel 2003
Office 2003

Sub blank1()
Sheets("Blank").Select
Sheets("Blank").Copy Before:=Sheets(1)
Sheets("Blank (2)").Select
Worksheets("Blank (2)").Name = Format(Date - 1, "mm-dd-
yyyy")
End Sub

thanks,
Mike
 
B

Bob Phillips

Sub blank1()
Dim oWs As Worksheet
On Error Resume Next
Set oWs = Sheets("Blank")
On Error GoTo 0
If Not oWs Is Nothing Then
oWs.Copy Before:=Sheets(1)
ActiveSheet.Name = Format(Date - 1, "mm-dd-yyyy")
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top