View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ian Coates Ian Coates is offline
external usenet poster
 
Posts: 21
Default Locking/unlocking cells

I have a subroutine (cutdown version below) which should lock and unlock
cells based on a cell content.

Private Sub ComboBox2_Change()
Worksheets(1).Unprotect
Application.ScreenUpdating = False

' ----- 17cm CHECK -----
If Range("w3").Value = 17 Then
Range("e9:o9").Locked = True
Else
Range("e9").Locked = False
Range("h9:i9").Locked = False
Range("k9").Locked = False
Range("m9:o9").Locked = False
End If
Worksheets(1).Protect
Application.ScreenUpdating = True

End Sub

W3 is the linked cell to combobox2.

If w3=17, there appears to be no problem, though the cells are already
locked.
If w3<17 I get an eror telling me that the Locked property can not be set
on the Range class.

It nust be something straightforward, but I can't see what.

Any ideas?

TIA

Ian