Add button to excel that is able to lock/unlock certain cells

excelnewbie132

New Member
Joined
Mar 12, 2019
Messages
1
Hi there!

I am new to this site and pretty much anything macro related.

I have a spreadsheet that I am trying to add a button and want it to have a macro on it that can lock/unlock the sheet or certain cells. I know that you can go to the "Review" tab and then protect the sheet or workbook from there, but I have a reason why I want a button.

This spreadsheet has a ton of formulas in it, and is going to be used by myself and many coworkers and then we will send to a client. I want my coworkers to be able to edit certain cells and then lock those cells before sending to the client. The reason I want a button is to make it as easy as possible for my coworkers to lock and remember to lock the cells before sending to clients. The button would help for those who don't know how to get to the protect sheet area on the review tab or forget, etc. Not everyone is excel savvy :)

Is this possible to do?

Thank you!
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,428
Hi,

It's simple enough. What exactly needs to be done, will you already have it setup ready to lock?

Just add a button or picture, and assign macro. Code as follows

Code:
Sub UnProtect()


Sheets("Sheet1").UnProtect Password:="myPassword"


End Sub


Sub Protect()


Sheets("Sheet1").Protect Password:="myPassword"


End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,109,380
Messages
5,528,366
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top