Locking/unlocking cells

I

Ian Coates

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:eek:9").Locked = True
Else
Range("e9").Locked = False
Range("h9:i9").Locked = False
Range("k9").Locked = False
Range("m9:eek:9").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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top