A way to programmitically lock cells?

H

Harald Staff

Record a macro while doing it and you're almost there.

HTH. Best wishes Harald
 
R

RPIJG

I did this, but now I have a reference to range error, what's wrong wit
this?


Code
-------------------
ActiveWorkbook.Worksheets("Sales Invoice").Range("B2:p57").Select
Selection.Locked = True
Selection.FormulaHidden = False
Worksheets("Customer Invoice").Range("B2:p56").Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveWorkbook.Worksheets("Sales Invoice").Range("C19").Selec
-------------------


I did have ActiveWorkbook.Worksheets("Custome
Invoice").Range("B2:p57").Select for that line, and it gave the sam
problem...do I have to activate the worksheet
 
H

Harald Staff

I said "almost". The errors would probably have to do with either selecting
(unnecessary, you almost never have to select or activate anything) or with
non-existing sheet names (you fix that). For the former, edit down to

Worksheets("Sales Invoice").Range("B2:p57").Locked = True
Worksheets("Customer Invoice").Range("B2:p56").Locked = True

HTH. Best wishes Harald
 
Top