Sheet naming question
You could integrate Chip Pearson's function to test if a sheet exists...
Function WorksheetExists(WSName As String, Optional WB As Workbook =
Nothing) As Boolean
On Error Resume Next
WorksheetExists = CBool(Len(IIf(WB Is Nothing, ThisWorkbook,
WB).Worksheets(WSName).Name))
End Function
Sub Tester()
If WorksheetExists(Date$) = True Then
ActiveSheet.Name = Date$ & "A"
Else
ActiveSheet.Name = Date$
End If
End Sub
--
Regards,
Rocky McKinley
"Mark R" wrote in message
...
As part of a series of macros, I name a new sheet that I open with the
current date with
ActiveSheet.Name = Date$
Occasionally I need to run this routine more than once in the same day,
which gives an error
Run time error "1004": Cannot rename a sheet to the same name as another
sheet . . ."
Is there a way to check if there is a sheet with the current date name,
and
then name the new sheet with an appendage - for example 12-21-2003A,
12-21-2003B etc. I know very little VBA, so as specific of code as
possible
would be greatly appreciated.
If that's unreasonably difficult, is there is a way to allow the macros to
continue past the error, without renaming the sheet in that case?
Thanks in advance
|