PDA

View Full Version : Locking blank cells only via VBA



keilah
04-02-2008, 06:04 AM
Public Sub Lock_Blanks()
Dim objCell As Range

ActiveSheet.Unprotect ""

On Error Resume Next
ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants).Locked = True
ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas).Locked = True
On Error GoTo 0

ActiveSheet.Protect ""
End Sub

Hi experts

i cannot amend the above to lock blank cells only any pointer for the non VBa person.

thanks

mdmackillop
04-02-2008, 06:12 AM
Why not lock eveything first, then unlock?

ActiveSheet.Cells.Locked = True
ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants).Locked = False
ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas).Locked = False

keilah
04-02-2008, 06:15 AM
thanks for the feed back