Thanks Julie.
I was successful.
Excellent.
"JulieD" wrote:
> Hi Jayant
>
> Here's some code that will generate this type of schedule for any year and
> any number of employees.
>
> 'start code
>
> Sub create_schedule()
> 'written by Julie Dall 2006
>
> Dim for_year As Long 'year to create schedule for
> Dim num_emp As Long 'number of employees to cater for
> Dim i, j, k, m As Long
>
> 'populate variables
> for_year = InputBox("Enter the year to create the schedule for",
> "Year?", Format(Now, "yyyy"))
> num_emp = InputBox("Enter the number of employees to cater for", "Number
> Employees", 10)
>
> Application.Workbooks.Add 'add a new workbook
>
> 'create schedule
> ActiveSheet.Range("A1").Select
>
> ActiveCell.Value = "Employee Absence Schedule for " & for_year
> ActiveCell.Font.Bold = True
> ActiveCell.Font.ColorIndex = 36
> ActiveCell.Interior.ColorIndex = 53
>
> For i = 1 To 12
> 'put months in
> ActiveCell.Offset(i + 1 + ((i - 1) * (num_emp + 3)), 0).Value =
> Format(DateSerial(for_year, i, 1), "mmmm yyyy")
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)), 0).Value =
> "Employee Name"
> 'format
> ActiveCell.Offset(i + 1 + ((i - 1) * (num_emp + 3)), 0).Font.Bold =
> True
> ActiveCell.Offset(i + 1 + ((i - 1) * (num_emp + 3)),
> 0).Font.ColorIndex = 36
> ActiveCell.Offset(i + 1 + ((i - 1) * (num_emp + 3)),
> 0).Interior.ColorIndex = 53
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)), 0).Font.Bold =
> True
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)),
> 0).Interior.ColorIndex = 19
> For k = 1 To num_emp + 1
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)) + k,
> 0).Interior.ColorIndex = 19
> Next
>
> 'put day header in
> For j = 1 To Day(DateSerial(for_year, i + 1, 0))
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)), j).Value =
> Left(Format(DateSerial(for_year, i, j), "ddd"), 1)
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)),
> j).Interior.ColorIndex = 19
> 'format
> For k = 0 To num_emp + 1
> If ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)),
> j).Value = "S" Then
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)) + k,
> j).Interior.ColorIndex = 19
> End If
> Next
> 'put days in
> For m = 1 To num_emp + 1
> ActiveCell.Offset(i + 2 + ((i - 1) * (num_emp + 3)) + m,
> j).Value = Format(DateSerial(for_year, i, j), "d")
> Next
> Next
> Next
>
> 'Fit columns
> Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
> Selection.Columns.AutoFit
> Range("A1").Select
> Columns(1).HorizontalAlignment = xlJustify
>
> MsgBox "Finished"
>
> End Sub
>
> 'end code
>
> this code can be copied & pasted into the code module of a workbook (line
> breaks removed) and when run, it will create a new workbook for you with the
> schedule information.
>
> If you would prefer, email me at the address below and i will send you a
> workbook containing the code.
>
> --
> Cheers
> JulieD
> Excel MVP
>
> julied_ng at hctsReMoVeThIs dot net dot au
>
>
> "Jayant" wrote:
>
> > Hi,
> > By default this template is for year 2005. I need it for year 2006. Any idea
> > how to get, how to chage?
> > Thanks
Bookmarks