Protect formulas in certain cells w/out using protect sheet due to linked macro

slivesay

Board Regular
Joined
Jan 4, 2019
Messages
64
I have 80+ templates that are use in my department. Each one has cells containing formulas. How can I protect certain cells w formulas from being deleted (deleted by user and by command button). I cannot use the protect sheet method - it will need to be vba and the vba needs to work on it own (no command buttons). One of the formulas is linked to two modules and the protect sheet method throws a error in the formula. This formula and vba attached to it make a barcode (shape) appear for each order number entered. The user keep deleting the formula in error and I'm having to go round and put back in each time. I need a way they cannot delete the formula and the formula still work to make barcode (which is a shape).

Thank you so much.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162
Hi Slivesay

I assume you want to write to cells using code but dont want anyone changing these cells
have you tried protect with UserInterface Only?
VBA Code:
sheet1.Protect UserInterfaceOnly:=True
 

slivesay

Board Regular
Joined
Jan 4, 2019
Messages
64
I haven't tried this. Would I put this in the sheet or a module?
Hi Slivesay

I assume you want to write to cells using code but dont want anyone changing these cells
have you tried protect with UserInterface Only?
VBA Code:
sheet1.Protect UserInterfaceOnly:=True
 

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162
It needs to go into a module but you can run it once and it will stay like that till you unprotect it
For a apssword as well use
VBA Code:
sheet1.Protect UserInterfaceOnly:=True, Password:="Hi"
 

slivesay

Board Regular
Joined
Jan 4, 2019
Messages
64

ADVERTISEMENT

It needs to go into a module but you can run it once and it will stay like that till you unprotect it
For a apssword as well use
VBA Code:
sheet1.Protect UserInterfaceOnly:=True, Password:="Hi"
It made all cells protected on one sheet and not the other. Plus, it cannot populate the barcode (shape) - the formula is connected to vba to create a shape.
 

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162
You will still need to unlock the cells you want users to enter data into like usual when protecting a sheet
this code just means the protection of the whole sheet is turned on for users only
 

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162

ADVERTISEMENT

highlight cells
right click ang click Format cells
goto Protection tab and uncheck Locked
cells are all locked by default
 

slivesay

Board Regular
Joined
Jan 4, 2019
Messages
64
highlight cells
right click ang click Format cells
goto Protection tab and uncheck Locked
cells are all locked by default
It throws this error in the formula cells that are tied w vba:

ERROR QRCode: The specified value is out of range
 

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162
What vba do you have?
Are you getting a value from a cell in vba?

I have just tested it and seems to work fine for getting and setting values
 

slivesay

Board Regular
Joined
Jan 4, 2019
Messages
64
What vba do you have?
Are you getting a value from a cell in vba?

I have just tested it and seems to work fine for getting and setting values
There is two modules w vba for this one formula. It takes the sales order number located in say A4 and creates its own barcode (msoAutoShape) and puts it in B4. B4 is where the formula is.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,172
Messages
5,640,583
Members
417,152
Latest member
DayTimeSeby

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
Top