LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default vba to lock columns b thru d based on value selected in col a

Assumptions

1. Columns B:D are locked.

2. Column A is unlocked.

3. Sheet protected with password of "justme" no quotes.

4. User can go back and change "Yes" to "No" which would re-lock the B:D
cells.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
Me.Unprotect Password:="justme"
n = Target.Row
If Me.Range("A" & n).Value = "Yes" Then
Me.Range("B" & n & ":D" & n).Locked = False
Else
Me.Range("B" & n & ":D" & n).Locked = True
End If
End If
enditall:
Application.EnableEvents = True
Me.Protect Password:="justme"
End Sub


Gord Dibben MS Excel MVP

On Wed, 11 Nov 2009 11:09:03 -0800, cm wrote:

This code needs to apply to one row at a time.

Column A - each cell has data validation -- possible values of Yes and No.

If the user chooses 'Yes' in A1, I need to unlock B1 thru D1 (and keep them
that way), otherwise those cells should be locked.

Same thing on row 2, etc, down to possible 300 rows or more.


 
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
How to lock the selected cells in 2007 Ashickur Excel Discussion (Misc queries) 4 January 18th 10 06:37 AM
Scroll Lock for selected multiple sheets Keyrookie Excel Worksheet Functions 2 December 4th 09 03:52 PM
Write macro to lock selected sheet when run office3000 Excel Discussion (Misc queries) 1 October 14th 08 06:49 PM
How to Lock the selected cells in Excel worksheet Siva New Users to Excel 1 May 8th 06 11:52 AM
How do I lock selected cells, so only I can change them? Robert Excel Worksheet Functions 3 February 27th 06 04:41 PM


All times are GMT +1. The time now is 03:34 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"