VBA & Combo Box (Form Control) Lock

jabobo422

New Member
Joined
Jun 6, 2024
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to create a tracker that my employees must update. Each employee has their own worksheet. The first worksheet is a splash page where they can click their name and it will automatically jump to the worksheet assigned to them.

There is also an overall worksheet for their leadership team and myself to review all employees at once. I've locked all the cells on this worksheet so they cannot be edited without a password; with one exception.

Should an employee not meet a certain threshold, a specific cell associated with them will be highlighted on the overall worksheet. I have placed a 'Combo Box (Form Control)' object next to these highlighted cells. This drop-down box will allow leadership to quickly select whether it's okay or not that the employee didn't meet this threshold (employee was on leave, had other assignments, wasn't approved, etc.). I'm having trouble locking these drop-down boxes from being edited. I can protect the overall worksheet, but this only locks editing of the text/options of the drop-down. I can still freely change the selection of the drop-down even when the sheet is completely locked.

Is there a way to make it so users cannot select/manipulate/change the drop-down when the worksheet is protected/locked?
 

Attachments

  • Capture.JPG
    Capture.JPG
    26.1 KB · Views: 16

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi & welcome to the board,

Are you protecting/unprotecting the worksheet via code or via the protect-sheet ribbon tab?
 
Upvote 0
Hi & welcome to the board,

Are you protecting/unprotecting the worksheet via code or via the protect-sheet ribbon tab?
Just the ribbon tab. I’m pretty beginner with VBA and macros; and don’t know how to protect with code.
 
Upvote 0
Just the ribbon tab. I’m pretty beginner with VBA and macros; and don’t know how to protect with code.
Ok- I think the only way you can achieve what you want is by toggling the DropDows Enabled Property to TRUE/FALSE. I don't know of a way to do this without resorting to vba.

- Hold the ALT key down and press F11. This will take you to the code editor.
- Add a new normal module to your project via Insert>Module from the vbe menu
- Copy the two following sub-routines and paste them in the Module white pane:
VBA Code:
Sub EanbleDropDowns()
    Sheet1.DropDowns.Enabled = True
End Sub

Sub DisbaleDropDowns()
    Sheet1.DropDowns.Enabled = False
End Sub

- Change Sheet1 to match the actual codename of the worksheet where you have the form dropdowns.

- Save the workbook.

As the subroutine names suggest, the first one is for enabling all the dropdowns in the worksheet and the second one is for disabling them.

You can execute the above subroutines, either from withing the vb editor by placing the keyborad cursor inside the subroutines and pressing the F5 key, or by assigning the subroutines to buttons in your worksheet.

You should run the EanbleDropDowns subrouine after having unprotected the worksheet and run the DisbaleDropDowns subroutine after having protected it.

I hope I have clearly explained the required steps. If you have any problems, just ask.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,764
Messages
6,180,840
Members
453,000
Latest member
JAO Esq

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