Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default protect cells after listbox selection

How can I protect a range of cells(Ex. A3:A6) after I pick a value from a
listbox.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default protect cells after listbox selection

Chay

This assumes you have all cells unlocked and sheet is protected with the
password "justme"

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B6")) Is Nothing Then
ActiveSheet.Unprotect Password:="justme"
With Target
If .Value = 3 Then
Range("A3:A6").Cells.Locked = True
End If
End With
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub

This is event code. Right-click on the sheet tab and "View Code"

Copy/paste into that sheet module.

Change Value = 3 to whatever value you will get from dropdown in B6


Gord Dibben MS Excel MVP




On Thu, 30 Nov 2006 00:07:00 -0800, Chay wrote:

How can I protect a range of cells(Ex. A3:A6) after I pick a value from a
listbox.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default protect cells after listbox selection

Thank you Gord Gibben for your code. Both of you guys helped me a lot. You
are pure geniuses. Thanks a million!!!!!!

"Gord Dibben" wrote:

Chay

This assumes you have all cells unlocked and sheet is protected with the
password "justme"

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B6")) Is Nothing Then
ActiveSheet.Unprotect Password:="justme"
With Target
If .Value = 3 Then
Range("A3:A6").Cells.Locked = True
End If
End With
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub

This is event code. Right-click on the sheet tab and "View Code"

Copy/paste into that sheet module.

Change Value = 3 to whatever value you will get from dropdown in B6


Gord Dibben MS Excel MVP




On Thu, 30 Nov 2006 00:07:00 -0800, Chay wrote:

How can I protect a range of cells(Ex. A3:A6) after I pick a value from a
listbox.



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
Password protect cells Christobo Excel Worksheet Functions 9 May 5th 10 02:34 PM
Linking Groups of cells between workbooks vnacj-joe Excel Discussion (Misc queries) 4 June 14th 07 05:18 PM
show the sum of an arbitary selection of cells Bob Oxley Excel Worksheet Functions 1 April 25th 06 07:55 PM
Protect Cells ??? Jcraig713 Excel Discussion (Misc queries) 2 January 27th 06 02:57 PM
How do I copy a LARGE selection of cells from Excel to powerpoint? Deadly Excel Discussion (Misc queries) 2 August 15th 05 03:21 PM


All times are GMT +1. The time now is 06:04 PM.

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

About Us

"It's about Microsoft Excel"