ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unlocking Cells (https://www.excelbanter.com/excel-programming/272062-re-unlocking-cells.html)

Tom Ogilvy

Unlocking Cells
 
You have defined names of SelectedFormulaRow and SelectedFormula

Range("SelectedFormulaRow, SelectedFormula, G16, G18").Select


Sub AAAA()
ActiveSheet.Unprotect
Range("SelectedFormulaRow, SelectedFormula, G16,G18 ").Select
Selection.Locked = False
Selection.FormulaHidden = False

End Sub

Worked fine for me whether the sheet was protected or unprotected (did not
have a password).

Regards,
Tom Ogilvy


"Sisilla" wrote in message
...
I have code that successfully unprotects a sheet before a
subroutine is run and protects it again after it is run. I
have more code in the subroutine that successfully unlocks
and then locks certain cells...IF THE SHEET IS MANUALLY
UNPROTECTED. The code is unable to unlock those cells if
the sheet is protected...EVEN THOUGH THERE IS CODE TO
UNPROTECT THE SHEET!

Does anyone have any ideas on what might be causing this?
I am on Excel XP, VB 6.3, and Windows 2000. I do not
receive a compile or run-time error. All the cells that
need to be unlocked manually have been unlocked. I am
positive that the message below pertains to the cells that
have to be unlocked through code:

The cell or chart you are trying to change is protected
and therefore read-only.

Here is my code:
ActiveSheet.Unprotect
Range("SelectedFormulaRow, SelectedFormula, G16,
G18").Select
Selection.Locked = False
Selection.FormulaHidden = False

Why will this code work only if the sheet has manually
been unprotected, and are there any suggestions about code
that will work even when the sheet is manually protected?
I appreciate any efforts to help me.

Thanks,
Sisilla





All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com