davie jonea
asked on
Quick way to protect/unprotect cells
HI
Is there any quick way I can protect and unprotect cells without selecting them all.
What im trying to do is all the cells that are YELLOW on my sheet I need them UNPROTECTED and the rest of the worksheet protected.
Any Ideas?
Is there any quick way I can protect and unprotect cells without selecting them all.
What im trying to do is all the cells that are YELLOW on my sheet I need them UNPROTECTED and the rest of the worksheet protected.
Any Ideas?
ASKER
Sorry Think I confused you. What im looking for is to be able to select the whole sheet and the cells that are yellow colour I need UNPROTECTED. or am I missing a bit I need to add to the macro
If you want to protect the cell, you can set cell's Locked property to be True. And Locked property to be False, if you want to unprotect the cell.
After that you can then protect the sheet using the code below.
After that you can then protect the sheet using the code below.
Sub Protect_Workbook(Para_Message As String)
Application.ScreenUpdating = True
Worksheets("Main Sheet").Protect Password:="12345"
End Sub
Here is the way to unprotect the sheet.
Sub Unprotect_Workbook(Para_Message As String)
Application.ScreenUpdating = False
Worksheets("Main Sheet").Unprotect Password:="12345"
End Sub
Chnge line 6 from
to
If cel.Interior.Color <> vbYellow Then
to
If cel.Interior.Color = vbYellow Then
ASKER
Sorry changed that and now comes up with run time error 424.
Did you include the Dim cel As Range line in my code?
Please supply a small sample workbook.
Please supply a small sample workbook.
ASKER
This is the actual workbook and im looking at locking everything apart from yellow cells on Data Input sheet. Copy of Copy of CubicSheet V1.3.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I’m glad I was able to help.
If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange Most Valuable Expert (MVE) 2015, 2017
Experts Exchange Distinguished Expert in Excel 2018
Experts Exchange Top Expert Visual Basic Classic 2012 to 2020
Experts Exchange Top Expert VBA 2018 to 2020
If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange Most Valuable Expert (MVE) 2015, 2017
Experts Exchange Distinguished Expert in Excel 2018
Experts Exchange Top Expert Visual Basic Classic 2012 to 2020
Experts Exchange Top Expert VBA 2018 to 2020
Open in new window
Open in new window
29222256.xlsm