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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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
 
Upvote 0
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
 
Upvote 0
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"
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
highlight cells
right click ang click Format cells
goto Protection tab and uncheck Locked
cells are all locked by default
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,293
Members
448,564
Latest member
ED38

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