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

Below is some combobox code code I'm having a problem with. Hopefully
someone can tell me where I'm going wrong. I've narrowed it down to the
problem area, but I'm not sure what's going wrong.

Private Sub ComboBox1_Change()
Worksheets(1).Unprotect
Worksheets(1).Range("B3").Locked = False
--------
More code
This part works OK
--------
Worksheets(1).Range("B3").Locked = True
Worksheets(1).Protect
End Sub

The code in the middle works fine (various If statements) so I've taken it
out. Without the "B3" lines, everything's OK. When the combobox changes, the
sheet is unlocked to allow changes to some of the cells, entering values and
locking/unlocking them as necessary. However, when I introduce the "B3"
lines I get an Excel error telling me the cell is protected. B3 is the
linked cell to the combobox. I wanted to avoid users being able to select
certain cells, including the ones linked to comboboxes.

Can anyone help?

Ian