VBA/Formula to lock cells when criteria is met

drewhx15

New Member
Joined
Jun 6, 2019
Messages
31
Hi All,

I hope that you can help me with this one.

I hope I explain this well.

OK so I am trying to make a spreadsheet that has 5 weeks, each week has Monday - Friday. OK so fairly straight forward. There are 4 available times: 08:00, 09:00, 17:00 & 18:30 (These have been added as a list via Data Validation).

08:00 has 4 places available, when 4 users select this time slot it cannot be selected throughout the rest of the week and ideally if someone tries to select 08:00 it would display a message or it would be greyed out and prevents the user from selecting that time.

Basically it counts the amount of 08:00 and deducts it from the 4 that are available and when the 4 are used, the 08:00 cannot be selected in that day of the week.

EMPLOYEEDayWeek 1Week 2Week 3Week 4Week 5
John DoeMonday09:00
Tuesday09:00
Wednesday09:00
Thursday09:00
Friday09:00
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Your data validation should have this formula...
VBA Code:
=IF(COUNTIF(F5:F8,">2"),Reduced_Times,All_Times)

Add two named ranges as Reduced_Times = 9:00,17:00,18:30 and All_Times = 8:00,9:00,17:00,18:30

Add a control cell to workout which times have been entered e.g.
Code:
=COUNTIF(F2:F5,"8:00")

The data validation points towards the control cell and picks the named range depending on the value.

You can remove the control cell and add the count if to the data validation formula but my skills are not that advanced!
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top