Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default naming sheets

is there a way to name sheets with a date using a macro?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default 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?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default 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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Help naming sheets jlclyde Excel Discussion (Misc queries) 8 November 20th 07 09:59 PM
Naming Sheets for day of the month Socks322 Excel Discussion (Misc queries) 0 November 7th 06 03:08 PM
Automatically naming sheets ForSale[_60_] Excel Programming 2 October 22nd 05 12:55 AM
naming sheets Christian Galbavy Excel Programming 2 May 16th 05 10:36 AM
Naming Workbooks and Sheets Mike Excel Programming 2 February 20th 04 05:55 PM


All times are GMT +1. The time now is 06:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"