View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Check for dated sheet

Mike,

Sounds like you are trying to do it more than once a day. Try this if so

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 Befo=Sheets(1)
ActiveSheet.Name = Format(Date - 1, "mm-dd-yyyy hh-mm-ss")
End If
End Sub


--
HTH

Bob Phillips

"Mike K" wrote in message
...
I tried the code that Bob gave me and it still errors on a
second macro run. "Run-time error '1004' Cannot rename a
sheet to the same name as another sheet". It adds the
sheet just fine the first time, but if I rerun the macro
it croaks when the sheet name has already been created.

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 Befo=Sheets(1)
ActiveSheet.Name = Format(Date - 1, "mm-dd-yyyy")
End If
End Sub


Mike