Password Protect Checkbox

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi,

I have looked into this for quite sometime but I haven't been able to get anything to work. Can someone help me please?

I currently have a check box which when ticked, returns the date in the same cell (Q7). However, I want to restrict who can check/uncheck this box with a password (password 123 for example).

My check box is called CheckboxDate1
I have renamed sheet1 to Work Bench

Along with standard VBA code possibly need to add a Userform as well? I have very little experience with this section (only discovered it today).

Little lost. Appreciate your help.

Thanks! :)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
A MouseMove event is the easiest way to handle this
- but only Active-X checkboxes have these
- the code is a single line

So if you have used FormControl checkbox, delete it and replace it with an Active-X checkbox and name it CheckboxDate1


Designer tab \ click on Design Mode \ right-click on checkbox \ View Code \ replace the default sub (CheckboxDate1_Click) with the one below:
Code:
Private Sub [COLOR=#ff0000]CheckboxDate1[/COLOR]_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If InputBox("Password") <> "123456" Then MsgBox "You cannot click here"
End Sub


Other request
possibly need to add a Userform as well?
- after testing above please explain what you are trying to achieve
 
Last edited:
Upvote 0
Thank you for suggesting a MouseMove.
I followed your instructions and now when my mouse goes near the tickbox it asks for a password. When I enter the password 123456 the window then disappears. However, then when I try to tick the box again after entering the password, the box to enter password just keeps coming up. So I can't tick the box. Any idea how I can correct this please? Thanks!
 
Upvote 0
For the operation "click this control to put the date in Q7", a check box is too complicated a control. A button should work.
Get a button from the Forms Menu and attach it to this macro.

If you really need a check box, get one from the Forms Menu and assign it to the same macro (un-comment-out the last 3 lines of code)


Code:
Sub PutDateWithPW()
    If Application.InputBox("Password please", default:="12345") <> "12345" then
        Range("Q7").Value = Date
    End IF
    'With ActiveSheet.Shapes(Application.Caller).ControlFormat
    '    .Value = IIf(.Value = xlON, xlOff, xlOn)
    'End With
End Sub
 
Upvote 0
The button with a password actually looks much better! However, it's not quite working right.
Firstly, when I click the button it comes up with the password box with the password 12345 already pre-populated in it rather than blank. If I press OK to 12345 it will not enter the date. If I enter no password and press OK or I press cancel, it enters the date.
 
Upvote 0
Oops, I got the inequality wrong. Change the <> to =.
I like to have my password entry pre-loaded with the correct password to save the user the hassle of entering in manually, but if you don't like that feature, you can remove the default argument from the InputBox.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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