naming sheets
is there a way to name sheets with a date using a macro?
|
naming sheets
Worksheets(1).Name = Format$(Date, "mmddyy") -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "jhyatt" wrote in message is there a way to name sheets with a date using a macro? |
naming sheets
Something like:
Sub dateit() ActiveSheet.Name = Format(Date, "dd_mm_yyyy") End Sub change the format to suit your needs -- Gary''s Student - gsnu200749 "jhyatt" wrote: is there a way to name sheets with a date using a macro? |
naming sheets
I have this code to add asheet with a2 as the date is it possible to do it
this way Sub AddNewSheet() Dim SheetName As String SheetName = Range("A2") Sheets(5).copy After:=Sheets(Sheets.Count) On Error GoTo ErrHandler: ActiveSheet.Name = SheetName Exit Sub ErrHandler: MsgBox SheetName & " is not a valid sheet name or is already used." End Sub "Gary''s Student" wrote: Something like: Sub dateit() ActiveSheet.Name = Format(Date, "dd_mm_yyyy") End Sub change the format to suit your needs -- Gary''s Student - gsnu200749 "jhyatt" wrote: is there a way to name sheets with a date using a macro? |
naming sheets
Your approach can be made to work. However, as you pointed out in the code,
you need to do an error check in case Range("A2").Value is not a legal sheetname or has aleady been used -- Gary''s Student - gsnu200749 "jhyatt" wrote: I have this code to add asheet with a2 as the date is it possible to do it this way Sub AddNewSheet() Dim SheetName As String SheetName = Range("A2") Sheets(5).copy After:=Sheets(Sheets.Count) On Error GoTo ErrHandler: ActiveSheet.Name = SheetName Exit Sub ErrHandler: MsgBox SheetName & " is not a valid sheet name or is already used." End Sub "Gary''s Student" wrote: Something like: Sub dateit() ActiveSheet.Name = Format(Date, "dd_mm_yyyy") End Sub change the format to suit your needs -- Gary''s Student - gsnu200749 "jhyatt" wrote: is there a way to name sheets with a date using a macro? |
naming sheets
so how would we get it to work?
thank you "Gary''s Student" wrote: Your approach can be made to work. However, as you pointed out in the code, you need to do an error check in case Range("A2").Value is not a legal sheetname or has aleady been used -- Gary''s Student - gsnu200749 "jhyatt" wrote: I have this code to add asheet with a2 as the date is it possible to do it this way Sub AddNewSheet() Dim SheetName As String SheetName = Range("A2") Sheets(5).copy After:=Sheets(Sheets.Count) On Error GoTo ErrHandler: ActiveSheet.Name = SheetName Exit Sub ErrHandler: MsgBox SheetName & " is not a valid sheet name or is already used." End Sub "Gary''s Student" wrote: Something like: Sub dateit() ActiveSheet.Name = Format(Date, "dd_mm_yyyy") End Sub change the format to suit your needs -- Gary''s Student - gsnu200749 "jhyatt" wrote: is there a way to name sheets with a date using a macro? |
All times are GMT +1. The time now is 11:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com