Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jayant
 
Posts: n/a
Default Employee Absence Schedule Template

Hi,
By default this template is for year 2005. I need it for year 2006. Any idea
how to get, how to chage?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
JulieD
 
Posts: n/a
Default Employee Absence Schedule Template

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
Jayant
 
Posts: n/a
Default Employee Absence Schedule Template

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
JulieD
 
Posts: n/a
Default Employee Absence Schedule Template

Hi Jayant

Glad to hear that it worked for you.

--
Cheers
JulieD

julied_ng at hctsReMoVeThIs dot net dot au


"Jayant" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
Lmorford
 
Posts: n/a
Default Employee Absence Schedule Template

LMorford; Is there any way some one can clarify what the below message
states and simplify the process to populate the current year for the employee
absence template?

"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



  #6   Report Post  
Posted to microsoft.public.excel.misc
LDP LDP is offline
external usenet poster
 
Posts: 3
Default Employee Absence Schedule Template



"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

  #7   Report Post  
Posted to microsoft.public.excel.misc
LDP LDP is offline
external usenet poster
 
Posts: 3
Default Employee Absence Schedule Template

I was unable to get the macro to run and received;
Compile error:
Syntax error
when I ran the macro below. I'm using excel 2003, any ideas??

"Jayant" wrote:

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

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Employee Absence Schedule Template

There were some very long lines in the code that wrapped to the next physical
line. I corrected those line wraps and the code worked fine for me:

Option Explicit
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 As Long
Dim j As Long
Dim k As Long
Dim 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


If it doesn't work, you'll want to be more specific about which lines cause the
errors.



LDP wrote:

I was unable to get the macro to run and received;
Compile error:
Syntax error
when I ran the macro below. I'm using excel 2003, any ideas??

"Jayant" wrote:

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


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
LDP LDP is offline
external usenet poster
 
Posts: 3
Default Employee Absence Schedule Template

Thanks Dave; it worked first time, you have the touch!!

"Dave Peterson" wrote:

There were some very long lines in the code that wrapped to the next physical
line. I corrected those line wraps and the code worked fine for me:

Option Explicit
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 As Long
Dim j As Long
Dim k As Long
Dim 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


If it doesn't work, you'll want to be more specific about which lines cause the
errors.



LDP wrote:

I was unable to get the macro to run and received;
Compile error:
Syntax error
when I ran the macro below. I'm using excel 2003, any ideas??

"Jayant" wrote:

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


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Employee Absence Schedule Template

I'm sure Julie is pleased that you got her code working.

LDP wrote:

Thanks Dave; it worked first time, you have the touch!!

"Dave Peterson" wrote:

There were some very long lines in the code that wrapped to the next physical
line. I corrected those line wraps and the code worked fine for me:

Option Explicit
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 As Long
Dim j As Long
Dim k As Long
Dim 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


If it doesn't work, you'll want to be more specific about which lines cause the
errors.



LDP wrote:

I was unable to get the macro to run and received;
Compile error:
Syntax error
when I ran the macro below. I'm using excel 2003, any ideas??

"Jayant" wrote:

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


--

Dave Peterson


--

Dave Peterson
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
Employee Work Schedule nzatmj Excel Discussion (Misc queries) 0 October 21st 05 09:34 PM
Change formula for Employee Shift Schedule template Pam Soreide Excel Worksheet Functions 1 September 7th 05 03:10 AM
Where can I find a template for a perpetual shift schedule. korcom2002 Excel Discussion (Misc queries) 0 June 15th 05 07:25 PM
Referencing a newly created worksheet Charyn Excel Worksheet Functions 2 May 2nd 05 04:13 AM
Employee Shift Schedule Excel template drhenrie Excel Discussion (Misc queries) 1 December 22nd 04 12:07 AM


All times are GMT +1. The time now is 02:36 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"