Checkbox maddness!

test3xc31

New Member
Joined
Jun 11, 2019
Messages
27
Office Version
  1. 2021
Platform
  1. Windows
Hi hoping someone can help me.
For some reason I cannot get the following to work.

when the checkbox is ticked i.e. TRUE
1. unlock cell named "merchant"
2. clear merchant contents (a formula)
3. message box "Enter Merchant"

(I've got this bit to work fine, where it falls apart is the following)

When the check box is unticked i.e. False
1. paste the preset formula back in the cell named "merchant"
2. and lock cell

It should be so simple! but its driving me mad!

Thankyou in advance. I'm expecting to face palm when I see the answer!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi & welcome to MrExcel.
Care to post the code you already have, along with the formula?
 
Upvote 0
This is what I have so far, It all functions appart from the cell locking. The sheet isn't password protected just protected. I've highlighted in red the lines of code that are not responding.

Thanks

Sub DataInput()


If ActiveSheet.CheckBoxes("Check Box 25").Value = 1 Then
On Error Resume Next
Range("Merchant").Select
Selection.Locked = Fals
ActiveCell.FormulaR1C1 = ""
MsgBox ("Enter Merchant")
Range("Merchant").Select

Else: Range("Merchant").Select
On Error Resume Next
ActiveCell.FormulaR1C1 = _
"=IF(Variety="""",""SELECT VARIETY"",IF(VLOOKUP(Variety,FixedData!R[11]C[-4]:R[16]C[-2],3,FALSE)="""",""Unspecified"",VLOOKUP(Variety,FixedData!R[11]C[-4]:R[16]C[-2],3,FALSE)))"
On Error Resume Next
Selection.Locked = True
Range("Destination").Select

End If
End Sub
 
Upvote 0
In what way doesn't it work?
Remove all 3 instances of this
Code:
On Error Resume Next
do you get any errors?
 
Upvote 0
In that case the sheet is protected & you will need to unprotect it like
Code:
ActiveSheet.Unprotect
and at the end of the code put
Code:
ActiveSheet.Protect
 
Upvote 0
In that case the sheet is protected & you will need to unprotect it like
Code:
ActiveSheet.Unprotect
and at the end of the code put
Code:
ActiveSheet.Protect

Face Palm! Thankyou! **** thats annoyed me!:beerchug:
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,101
Messages
6,170,116
Members
452,302
Latest member
TaMere

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