Newbie at Vb need help

MinionMan63

New Member
Joined
Apr 4, 2019
Messages
4
I have 3 cells that have a macro to change values via a command button and ctrl + R and ctrl + D. Those values change color as well with conditional formatting so you can see the change. How do I lock those cells with out getting a Vb error "1004". At which time I need to reboot pc. Basically I need to lock the cells so you do not damage the values or change the values, then unlock them so the macro can run and then re lock them. If you lock the cells using the format cells properties, then that is when I get the error code. Is there a way to unlock the 3 cells and allow the change then re lock them after they change value.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
If I am understanding correctly, you are protecting the worksheet (after locking the cells) and then getting that error when you try to modify the cells using VBA code. If that is correct, then it means you did not unprotect the worksheet within your code prior to trying to change the cell. The worksheet object has an Unprotect method that you need to call. For example...

Sheets("Sheet1").Unprotect

The Unprotect method can take an optional password argument if you protected the worksheet with a password. After making the changes you want, reestablish protection...

Sheet("Shee1").Protect

Again, you would provide a password if you wanted the sheet to be password protected. You should check the help files for the Protect method as you can tailor the type of protection via code in the same way as you can do with the protection dialog box.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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