Drop Down List Triggering Macro

Leeinsa

Board Regular
Joined
Jul 24, 2009
Messages
96
I have a drop down box on a worksheet which allows users to select from a list. Depending on what they select, I then use the link cell to determine which rows in the sheet should be visible and which should be hidden.

All is well until I protect the sheet to stop the users from un-hiding and changing things they should not. When the sheet is protected, Excel wont let the Link cell update when the user selects from the drop down box, because the link cell is now locked.

So what i need is the following:

When the user clicks on their selection in the drop down box, The sheet to become unprotected, the relevant rows to be hidden or unhidden, then the sheet to be protected again.

Can anyone help me with the correct commands and more importantly where they should be to trigger it at the right time, I cannot find a way of running code when changes are made to the actual drop down list. (Hence the use of the link cell).
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Enter design mode (available from the toolbar at View > Toolbars > Control Toolbox) and doubleclick on your combobox. VBE should open and put you in "Private Sub ComboBox1_Change()". This is where your code goes.

Code:
ActiveSheet.Unprotect
Rows("1:1").Hidden = True
Rows("12-17").Hidden = False
ActiveSheet.Protect
 
Upvote 0
Many thanks Phox, You just made number 2 on my hero list. Now i know how to get at the properties of the actual elements I use on my sheets. Thanks again.

Lee.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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