davisbrc
01-30-2009, 09:04 AM
I am a VB noob, so I am wondering what needs to be changed in this code to allow me to lock all the cells in every sheet, except for cells that are yellow.
Dim wSht As Worksheet
Dim allwShts As Sheets
Set allwShts = Worksheets
On Error Resume Next
For I = 1 To Sheets.Count
Sheets(I).Activate
ActiveSheet.Unprotect Password:=""
Application.ScreenUpdating = False
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants).Select
Selection.Locked = True
Selection.FormulaHidden = True
ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas).Select
Selection.Locked = True
Selection.FormulaHidden = True
ActiveSheet.Protect Password:=""
Application.ScreenUpdating = True
Next I
Dim wSht As Worksheet
Dim allwShts As Sheets
Set allwShts = Worksheets
On Error Resume Next
For I = 1 To Sheets.Count
Sheets(I).Activate
ActiveSheet.Unprotect Password:=""
Application.ScreenUpdating = False
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants).Select
Selection.Locked = True
Selection.FormulaHidden = True
ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas).Select
Selection.Locked = True
Selection.FormulaHidden = True
ActiveSheet.Protect Password:=""
Application.ScreenUpdating = True
Next I