Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks so much. This worked perfectly.
"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... On Error Resume Next ActiveSheet.Name = Date$ On Error GoTo 0 Or more sopisticated: Sub NameAsDate() Dim s As String s = Date$ If Not WorksheetExists(s) Then ActiveSheet.Name = s Else Dim i As Integer Do Until Not WorksheetExists(s) s = Date$ & Chr(65 + i) i = i + 1 Loop ActiveSheet.Name = s End If End Sub Function WorksheetExists(wsName As String, _ Optional wbName As String) As Boolean If wbName = "" Then wbName = _ ActiveWorkbook.Name On Error Resume Next WorksheetExists = CBool(Len(Workbooks(wbName) _ .Worksheets(wsName).Name)) End Function -- Vasant "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Naming a sheet | Excel Discussion (Misc queries) | |||
Naming Sheet | Excel Discussion (Misc queries) | |||
Chart Axis naming question | Charts and Charting in Excel | |||
Question about tab naming and referenced cells | Excel Discussion (Misc queries) | |||
Yet another question naming ranges | Excel Programming |