View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ordnance1[_2_] ordnance1[_2_] is offline
external usenet poster
 
Posts: 92
Default Prevent clicking on a cell

Rick I have sent this twice but it does not seem to be displaying so I will
try again.

Sure

Just a little background. I am creating a vacation calendar for a workgroup
of about 185 people in 3 different workgroups. Since the number of vacation
days available is a percentage of the number of employees in each workgroup
(each workgroup having its own quota). Just to add some complication to this
the number of people allowed off on Saturdays and Sundays is different from
the rest of the week. I want to build in the ability to expand (never know
if the economy will improve) or constrict if (my have some layoffs in July).

So to deal with Saturdays and Sundays where the number allowed off is
different than weekdays (and Saturdays and Sundays are not the same number).
For the sake of speed in populating the calendar we want the ability to
select the whole week (by selecting the first cell and dragging across to
the last cell) and have the userform place the selected name in the each
cell. All of that is working but I wanted to prevent someone fro selecting a
Saturday or Sunday that is not actually available.

So I envision having to do this for each Saturday and Sunday. The = # will
go from 0 to 18 The Range # ( "Q7" ) will be different for each day.

If Range("Q7") = 0 Then
If Not Intersect(Target, Range("B5:C5")) Is Nothing Then
MsgBox "You have selected a day that is not available for vacation.
Please reselect."
Range("A").Select
End
End If
End If

If Range("Q7") = 1 Then
If Not Intersect(Target, Range("B5:C5")) Is Nothing Then
MsgBox "You have selected a day that is not available for vacation.
Please reselect."
Range("A3").Select
End
End If
End If

If Range("Q7") = 3 Then
If Not Intersect(Target, Range("B5:C5")) Is Nothing Then
MsgBox "You have selected a day that is not available for vacation.
Please reselect."
Range("A3").Select
End
End If
End If



"ordnance1" wrote in message
...
I want to run the code below to prevent a range of cells from being
selected if the Range("Q7") = 1. I have all cells on the worksheet locked
but the user must be able to click on the locked cells to trigger a
userform so I have to check Select Locked Cells. So is there any way make
the Range("B5:C5") unselectable?



If Range("Q7") = 1 Then
Range("B5:C5").Locked = True
End If