Akashwani
Well-known Member
- Joined
- Mar 14, 2009
- Messages
- 2,911
Good day,
I was helping someone here....
http://www.mrexcel.com/forum/showthread.php?t=546934
Out of curiosity I thought that I would create a Template so that it could be copied and used for the year. I have put together the following code from recording Macros and some MrExcel VBA....
I know that the Template and code are not perfect, so no laughing or mockery please I am open to suggestions on the following....
1. How can the code above be changed so the Sheets Array doesn't have to be manually changed IF someone wants 6 months or 24 months?
2. What code would be required to put the dates in column A for each work sheet based on the sheet name, eg sheet name January would have code to create the dates in column A for that month.
Sample of Template....
There is a file here for anyone interested in using this Template or who would like to look at it and make any suggestions.....
MonthlyTimeSheet.xls
This file contains the above VBA ONLY.
Thank you for viewing this and any ideas will be greatly appreciated.
Ak
I was helping someone here....
http://www.mrexcel.com/forum/showthread.php?t=546934
Out of curiosity I thought that I would create a Template so that it could be copied and used for the year. I have put together the following code from recording Macros and some MrExcel VBA....
Code:
Sub AddMonthSheets()
Application.ScreenUpdating = False
''This currently selects the cells in A2:A13 on sheet Criteria.
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
''The following creates new sheets based on the names in the above range
For Each Cell In Selection
Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Cell.Value
Next Cell
''This copies sheet Template
Sheets("Template").Select
Cells.Select
Selection.Copy
''Change this array to suit the names listed in A2:A13 on sheet Criteria
''This selects the sheets below and pastes the template on to each sheet
Sheets(Array("January", "February", "March", "April", "May", "June", "July", "August", _
"September", "October", "November", "December")).Select
Sheets("January").Activate
ActiveSheet.Paste
Range("A1").Select
Sheets("Template").Select
Application.CutCopyMode = False
Range("A1").Select
Sheets("Criteria").Select
Range("A1").Select
Application.ScreenUpdating = True
End Sub
I know that the Template and code are not perfect, so no laughing or mockery please I am open to suggestions on the following....
1. How can the code above be changed so the Sheets Array doesn't have to be manually changed IF someone wants 6 months or 24 months?
2. What code would be required to put the dates in column A for each work sheet based on the sheet name, eg sheet name January would have code to create the dates in column A for that month.
Sample of Template....
Excel Workbook | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | |||
1 | ",CELL("filename",A1))+1,256)]Template | * | * | * | * | * | * | * | * | * | * | * | * | * | ||
2 | Date | Day | Time-In | Time-Out | Daily Total Hrs | Reg. Hrs (8 hr) | Week OT | W/E OT | Holiday OT | Tardiness | Sick Leave | Absence | Unpaid Leave | Holiday | ||
3 | * | * | * | * | * | * | * | * | * | * | * | * | * | * | ||
4 | * | * | * | * | * | * | * | * | * | * | * | * | * | * | ||
5 | * | * | * | * | * | * | * | * | * | * | * | * | * | * | ||
Template |
There is a file here for anyone interested in using this Template or who would like to look at it and make any suggestions.....
MonthlyTimeSheet.xls
This file contains the above VBA ONLY.
Thank you for viewing this and any ideas will be greatly appreciated.
Ak