Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ian
It shouldn't matter whether or not B3 is locked; all cells are by default. It only has any effect when the sheet is protected. As the problem referes to B3 I'd delete any reference to it in the macro. Hope it works Regards Peter -----Original Message----- 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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ComboBox for a range of cells | Excel Discussion (Misc queries) | |||
Locked worksheet & hyperlinks (w/ select locked cells unchecked) | Excel Discussion (Misc queries) | |||
Combobox locked | Excel Discussion (Misc queries) | |||
paste locked cells and unlocked cells in protected sheet | Excel Worksheet Functions | |||
Put comments on a locked spreadsheet even though cells not locked | Excel Worksheet Functions |