Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
John N
 
Posts: n/a
Default Staff availability worksheet

I have set up a basic staff availablility worksheet in excel for my team.
Basically it has staff names down the right side and a timeline across the
top. Staff select an appropriate range of cells adjacent thier name and use a
colour code to indicate meetings, leave etc. We currently do this by
selecting "Format" then "patterns" and clicking on a colour. We also have a
"Key" section on the worksheet which shows which colour should be used for
what.
It would be a lot easier if we could select the range of cells and then just
click on the appropriate colour in the "key" section, and have that colour
then applied to the selected range of cells.

Is this possible ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Staff availability worksheet

John,

Here is a way.

Assuming that the blocks are B2:Q10 (you can configure this in the code),
and you have a key table in column U with the colours, and some key value to
associate with the colours, such as M for meetings, L for Leave, etc.. When
you want to allocate a block, select all the cells, enter the time id (M, L
etc.) then hit Ctrl-Enter. This loads the value in all the cells. Add this
code to process that input

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B2:Q20"
Dim cell As Range
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
For Each cell In Target
On Error Resume Next
iPos = Application.Match(cell.Value, Columns("U:U"), 0)
On Error GoTo 0
If iPos 0 Then
cell.Interior.ColorIndex = Cells(iPos,
"U").Interior.ColorIndex
cell.Font.ColorIndex = Cells(iPos, "U").Interior.ColorIndex
End If
Next cell
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"John N" <John wrote in message
...
I have set up a basic staff availablility worksheet in excel for my team.
Basically it has staff names down the right side and a timeline across the
top. Staff select an appropriate range of cells adjacent thier name and

use a
colour code to indicate meetings, leave etc. We currently do this by
selecting "Format" then "patterns" and clicking on a colour. We also have

a
"Key" section on the worksheet which shows which colour should be used for
what.
It would be a lot easier if we could select the range of cells and then

just
click on the appropriate colour in the "key" section, and have that colour
then applied to the selected range of cells.

Is this possible ?



  #3   Report Post  
Posted to microsoft.public.excel.misc
John N
 
Posts: n/a
Default Staff availability worksheet

Hello Bob

Sorry not to get back to you earlier, but I am not that familiar with using
VB, and I have not been able to make it work. I copied the code as suggested
and modified the range details to match the ones used in my sheet - but with
no success.

I know its a lot to ask - but is there any chance you could have a look at
the worksheet and see what I am doing wrong. It sounds like such a good
solution, I would love to get it to work.

John



"Bob Phillips" wrote:

John,

Here is a way.

Assuming that the blocks are B2:Q10 (you can configure this in the code),
and you have a key table in column U with the colours, and some key value to
associate with the colours, such as M for meetings, L for Leave, etc.. When
you want to allocate a block, select all the cells, enter the time id (M, L
etc.) then hit Ctrl-Enter. This loads the value in all the cells. Add this
code to process that input

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B2:Q20"
Dim cell As Range
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
For Each cell In Target
On Error Resume Next
iPos = Application.Match(cell.Value, Columns("U:U"), 0)
On Error GoTo 0
If iPos 0 Then
cell.Interior.ColorIndex = Cells(iPos,
"U").Interior.ColorIndex
cell.Font.ColorIndex = Cells(iPos, "U").Interior.ColorIndex
End If
Next cell
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"John N" <John
wrote in message
...
I have set up a basic staff availablility worksheet in excel for my team.
Basically it has staff names down the right side and a timeline across the
top. Staff select an appropriate range of cells adjacent thier name and

use a
colour code to indicate meetings, leave etc. We currently do this by
selecting "Format" then "patterns" and clicking on a colour. We also have

a
"Key" section on the worksheet which shows which colour should be used for
what.
It would be a lot easier if we could select the range of cells and then

just
click on the appropriate colour in the "key" section, and have that colour
then applied to the selected range of cells.

Is this possible ?




  #4   Report Post  
Posted to microsoft.public.excel.misc
John N
 
Posts: n/a
Default Staff availability worksheet

Ooops ! Spotted my mistake - the solution is now working fine.

Many thanks for your help Bob.

"John N" wrote:

Hello Bob

Sorry not to get back to you earlier, but I am not that familiar with using
VB, and I have not been able to make it work. I copied the code as suggested
and modified the range details to match the ones used in my sheet - but with
no success.

I know its a lot to ask - but is there any chance you could have a look at
the worksheet and see what I am doing wrong. It sounds like such a good
solution, I would love to get it to work.

John



"Bob Phillips" wrote:

John,

Here is a way.

Assuming that the blocks are B2:Q10 (you can configure this in the code),
and you have a key table in column U with the colours, and some key value to
associate with the colours, such as M for meetings, L for Leave, etc.. When
you want to allocate a block, select all the cells, enter the time id (M, L
etc.) then hit Ctrl-Enter. This loads the value in all the cells. Add this
code to process that input

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B2:Q20"
Dim cell As Range
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
For Each cell In Target
On Error Resume Next
iPos = Application.Match(cell.Value, Columns("U:U"), 0)
On Error GoTo 0
If iPos 0 Then
cell.Interior.ColorIndex = Cells(iPos,
"U").Interior.ColorIndex
cell.Font.ColorIndex = Cells(iPos, "U").Interior.ColorIndex
End If
Next cell
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"John N" <John
wrote in message
...
I have set up a basic staff availablility worksheet in excel for my team.
Basically it has staff names down the right side and a timeline across the
top. Staff select an appropriate range of cells adjacent thier name and

use a
colour code to indicate meetings, leave etc. We currently do this by
selecting "Format" then "patterns" and clicking on a colour. We also have

a
"Key" section on the worksheet which shows which colour should be used for
what.
It would be a lot easier if we could select the range of cells and then

just
click on the appropriate colour in the "key" section, and have that colour
then applied to the selected range of cells.

Is this possible ?




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
Protect Workbook vs Worksheet?? Dan B Excel Worksheet Functions 3 November 7th 05 09:02 PM
Search/Match between 2 x separate Worksheets and populate result in third worksheet Alan Bartley Excel Discussion (Misc queries) 1 April 11th 05 05:21 AM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
copyright and worksheet protection dow Excel Discussion (Misc queries) 2 January 3rd 05 03:07 PM
Executing macro for all worksheet from a different worksheet Biti New Users to Excel 3 December 8th 04 10:05 AM


All times are GMT +1. The time now is 10:03 PM.

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

About Us

"It's about Microsoft Excel"