#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Combo box

I am trying to make a cell Locked or Unlocked by using the Combo Box value.
But when I click on one of the Combo drop down values, I get the message:
"The cell is protected and can not be wriiten to"
Any Suggestions?
Aksel

Private Sub ComboBox3_Change()
ActiveSheet.Unprotect password:="*******"
Application.ScreenUpdating = False

If ComboBox3.Value = "NONE" Then GoTo Line1 Else GoTo Line2
Line1:
'Protect Cell G18
With ActiveSheet.Range("G18")
..FormulaR1C1 = ""
..Locked = True
..Interior.ColorIndex = 15
End With
GoTo Lastline
Line2:
Unprotect the Cell G18
With ActiveSheet.Range("G18")
..Locked = False
..Interior.ColorIndex = xlNone
End With
Lastline:
ActiveSheet.Range("J24").Select
ActiveSheet.Protect password:="driller", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Combo box

Aksel,

You have to unlock the sheet with the same password
that you locked it with. In the following revised code,
I added the unprotect password, simplified
the code a little and eliminated the goto lines...

'-----------------------------------------------------------
Private Sub ComboBox3_Change()
Application.ScreenUpdating = False
Me.Unprotect Password:="driller"

If ComboBox3.Value = "NONE" Then
'Protect Cell G18
With Me.Range("G18")
.FormulaR1C1 = ""
.Locked = True
.Interior.ColorIndex = 15
End With
Else
'Unprotect the Cell G18
With Me.Range("G18")
.Locked = False
.Interior.ColorIndex = xlNone
End With
End If

Lastline:
Me.Range("J24").Select
Me.Protect Password:="driller", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub
'-----------------------------------------------------------------

Regards,
Jim Cone
San Francisco, USA




"aksel børve" wrote in message
...
I am trying to make a cell Locked or Unlocked by using the Combo Box value.
But when I click on one of the Combo drop down values, I get the message:
"The cell is protected and can not be wriiten to"
Any Suggestions?
Aksel

- snip -

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking a form combo box... results from the combo box to another Trey Excel Discussion (Misc queries) 1 July 15th 07 01:58 AM
combo reference on another combo box for picking address etc. kbjin Excel Worksheet Functions 1 December 8th 06 03:29 PM
Can one combo box control the data in a different combo box MarkM Excel Discussion (Misc queries) 5 October 9th 06 11:44 AM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 1 February 16th 05 02:05 AM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 0 February 15th 05 07:45 PM


All times are GMT +1. The time now is 11:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"