![]() |
How can I get excel to label sheets automatically? eg: dates.
I want Excel to label my sheets automatically, because I make a workbook
every month and I don't feel like entering every date on every tab. Is this possible? |
How can I get excel to label sheets automatically? eg: dates.
Do you need a dated tab name for every day of each month?
|
How can I get excel to label sheets automatically? eg: dates.
Yes that is exactly what I need.
"Dave O" wrote: Do you need a dated tab name for every day of each month? |
How can I get excel to label sheets automatically? eg: dates.
I have a very similar situation. I have a new workbook for every month and a worksheet in that workbook for every day of the month. My solution is not very elegant: I created a workbook, Deleted all but one sheet, Did the formatting I want for every day in that first sheet. Headers, number formats, etc. Copied the sheet 30 more times Numbered each sheet 01, 02, ... , 30, & 31 Then save the sheet as an original or as a template. Template is best so you don't screw up you orignal as easily. Then just use that one to copy for each month. A simple macro could also be created to insert and name new sheets in consecutive order if the formatting & headers are not as critical. -- DCSwearingen ------------------------------------------------------------------------ DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506 View this thread: http://www.excelforum.com/showthread...hreadid=542592 |
How can I get excel to label sheets automatically? eg: dates.
Start a new workbook
Add this code to a general module in that workbook's project Option Explicit Sub testme() Dim iCtr As Long Dim NewWkbk As Workbook Dim HowMany As Long Dim StartDate As Date StartDate = DateSerial(Year(Date), Month(Date) + 1, 1) StartDate = Application.InputBox(prompt:="Enter a date in the month you want", _ Type:=1, Default:=Format(StartDate, "mmmm dd, yyyy")) If Year(StartDate) < 2005 _ Or Year(StartDate) 2010 Then Exit Sub End If StartDate = DateSerial(Year(StartDate), Month(StartDate), 1) 'First of the month! HowMany = Day(DateSerial(Year(StartDate), Month(StartDate) + 1, 0)) Set NewWkbk = Workbooks.Add(1) 'single sheet NewWkbk.Sheets.Add Count:=HowMany - 1 For iCtr = 1 To HowMany NewWkbk.Worksheets(iCtr).Name _ = Format(StartDate - 1 + iCtr, "yyyy_mm_dd") Next iCtr End Sub Back to excel put a giant button from the Forms toolbar on the first worksheet in that new workbook. Assign this macro to the button. Save this workbook. Open the workbook when you want to create a new workbook for the month and click the giant button. Adrian wrote: I want Excel to label my sheets automatically, because I make a workbook every month and I don't feel like entering every date on every tab. Is this possible? -- Dave Peterson |
How can I get excel to label sheets automatically? eg: dates.
No real change--just fixing line wrapping!
Option Explicit Sub testme() Dim iCtr As Long Dim NewWkbk As Workbook Dim HowMany As Long Dim StartDate As Date StartDate = DateSerial(Year(Date), Month(Date) + 1, 1) StartDate = Application.InputBox _ (prompt:="Enter a date in the month you want", _ Type:=1, Default:=Format(StartDate, "mmmm dd, yyyy")) If Year(StartDate) < 2005 _ Or Year(StartDate) 2010 Then Exit Sub End If 'First of the month! StartDate = DateSerial(Year(StartDate), Month(StartDate), 1) HowMany = Day(DateSerial(Year(StartDate), Month(StartDate) + 1, 0)) Set NewWkbk = Workbooks.Add(1) 'single sheet NewWkbk.Sheets.Add Count:=HowMany - 1 For iCtr = 1 To HowMany NewWkbk.Worksheets(iCtr).Name _ = Format(StartDate - 1 + iCtr, "yyyy_mm_dd") Next iCtr End Sub Dave Peterson wrote: Start a new workbook Add this code to a general module in that workbook's project <<snipped Back to excel put a giant button from the Forms toolbar on the first worksheet in that new workbook. Assign this macro to the button. Save this workbook. Open the workbook when you want to create a new workbook for the month and click the giant button. Adrian wrote: I want Excel to label my sheets automatically, because I make a workbook every month and I don't feel like entering every date on every tab. Is this possible? -- Dave Peterson -- Dave Peterson |
How can I get excel to label sheets automatically? eg: dates.
Thank you very much!!!!!!
"Dave Peterson" wrote: Start a new workbook Add this code to a general module in that workbook's project Option Explicit Sub testme() Dim iCtr As Long Dim NewWkbk As Workbook Dim HowMany As Long Dim StartDate As Date StartDate = DateSerial(Year(Date), Month(Date) + 1, 1) StartDate = Application.InputBox(prompt:="Enter a date in the month you want", _ Type:=1, Default:=Format(StartDate, "mmmm dd, yyyy")) If Year(StartDate) < 2005 _ Or Year(StartDate) 2010 Then Exit Sub End If StartDate = DateSerial(Year(StartDate), Month(StartDate), 1) 'First of the month! HowMany = Day(DateSerial(Year(StartDate), Month(StartDate) + 1, 0)) Set NewWkbk = Workbooks.Add(1) 'single sheet NewWkbk.Sheets.Add Count:=HowMany - 1 For iCtr = 1 To HowMany NewWkbk.Worksheets(iCtr).Name _ = Format(StartDate - 1 + iCtr, "yyyy_mm_dd") Next iCtr End Sub Back to excel put a giant button from the Forms toolbar on the first worksheet in that new workbook. Assign this macro to the button. Save this workbook. Open the workbook when you want to create a new workbook for the month and click the giant button. Adrian wrote: I want Excel to label my sheets automatically, because I make a workbook every month and I don't feel like entering every date on every tab. Is this possible? -- Dave Peterson |
How can I get excel to label sheets automatically? eg: dates.
Many Thanks to Dave Peterson!! In my earlier, not so elegant way of doing this, I wanted to maintain my report formatting. I copied that formatting to the the worksheet with the macro button and saved my workbook with this macro as "Add_CR_Workbook.xls" and added the following to the end of Dave code: Windows("Add_CR_Workbook.xls").Activate Cells.Copy Windows(NewWkBkName).Activate For iCtr = 1 To Worksheets.Count Sheets(iCtr).Select Cells.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Next iCtr -- DCSwearingen ------------------------------------------------------------------------ DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506 View this thread: http://www.excelforum.com/showthread...hreadid=542592 |
How can I get excel to label sheets automatically? eg: dates.
Glad you got your variation working.
Another way to do this would be to do that formatting to the first worksheet. Then copy that first worksheet lots of times (instead of inserting a new "generic" worksheet). DCSwearingen wrote: Many Thanks to Dave Peterson!! In my earlier, not so elegant way of doing this, I wanted to maintain my report formatting. I copied that formatting to the the worksheet with the macro button and saved my workbook with this macro as "Add_CR_Workbook.xls" and added the following to the end of Dave code: Windows("Add_CR_Workbook.xls").Activate Cells.Copy Windows(NewWkBkName).Activate For iCtr = 1 To Worksheets.Count Sheets(iCtr).Select Cells.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Next iCtr -- DCSwearingen ------------------------------------------------------------------------ DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506 View this thread: http://www.excelforum.com/showthread...hreadid=542592 -- Dave Peterson |
How can I get excel to label sheets automatically? eg: dates.
yes I do!
"Adrian" wrote: Yes that is exactly what I need. "Dave O" wrote: Do you need a dated tab name for every day of each month? |
All times are GMT +1. The time now is 01:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com