I wouldn't use "SelectionChange" because that would run whenever you SELECT a 
cell.
I would use the Change event.

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim pwd
    pwd = "test"
    If Target.Column = 3 Then
            ActiveSheet.Unprotect Password:=pwd
        If (Target.Value <> "") Then
            Cells(Target.Row, "D").Locked = True
        Else
            Cells(Target.Row, "D").Locked = False
        End If
        ActiveSheet.Protect Password:=pwd
    End If
End Sub

 
Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------




________________________________
From: Santosh Singh <str1...@gmail.com>
To: excel-macros@googlegroups.com
Sent: Mon, August 20, 2012 11:47:43 AM
Subject: Re: $$Excel-Macros$$ help for Conditional Lock and unlock cells


Dear Paul, 
First let me thanks you for prompt reply.
i have tried  this ...

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If 
Range("a4:a10").Value = "" Then Range("b4:B10").Locked = False Else 
Range("b4:b10").Locked = True End If End Sub

But is not working 

 sheet can be protected via password .
if any formula is there is so good or v can go VBA as i tried but its not 
working.


Thanks And  Regards,

SANTOSH KUMAR SINGH
+917702004100



On Mon, Aug 20, 2012 at 9:05 PM, Paul Schreiner <schreiner_p...@att.net> wrote:

Your request is somewhat confusing.
>
>"locking" a cell does not necessarily mean "grayed out".
>In order to lock a cell, two things have to happen.
>1) the "locked" property of the cell must be set.
>2) the sheet has to be protected (with or without a password)
>
>For the cell to be "Grayed Out" means that the font is a light gray.
>These two events are independent.
>
>Now, it IS possible to create an event that checks for a change in Column C.
>If the cell has a value, a)uprotect the sheet, b) change the "locked" 
>property  
>to "true" on the cell in the same row as the changed cell, and column "D", c) 
>change the font color to Gray.
>
>You didn't mention it, but were you looking for a VBA solution?
>what version of excel are you using?
>what do you know about VBA programming?
>what have you tried?
>
>Now, about the "vice versa":
>The term means "the other way around".
>So, do you mean that if a cell in column D has a value, then the corresponding 
>cell in column C gets locked?
>or do you simply mean that if C is blank, the D is UNLOCKed?
>
> 
>Paul
>-----------------------------------------
>“Do all the good you can,
>By all the means you can,
>In all the ways you can,
>In all the places you can,
>At all the times you can,
>To all the people you can,
>As long as ever you can.” - John Wesley
>-----------------------------------------
>
>
>
>
>
________________________________
From: Santosh Kumar Singh <str1...@gmail.com>
>To: excel-macros@googlegroups.com
>Sent: Mon, August 20, 2012 11:05:20 AM
>Subject: $$Excel-Macros$$ help for Conditional Lock and unlock cells
>
>
>
>Hay looking for help ..
> 
> Column       C   D  
>    open for entry  
> a   Locked  
> d   Locked  
> a   Locked  
>    open for entry  
>If any value is in Column C Cells then Column D Cell   (In same row) get 
>locked 
>(Grayed out) and vice versa.
> 
>Thanks And regards,
>Santosh-- 
>Join official facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES (1120+ members already BANNED for violation)
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
> 
>2) Don't post a question in the thread of another member.
> 
>3) Don't post questions regarding breaking or bypassing any security measure.
> 
>4) Acknowledge the responses you receive, good or bad.
> 
>5) Cross-promotion of, or links to, forums competitive to this forum in 
>signatures are prohibited. 
>
> 
>6) Jobs posting is not allowed.
> 
>7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
> 
>NOTE : Don't ever post personal or confidential data in a workbook. Forum 
>owners 
>and members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To post to this group, send email to excel-macros@googlegroups.com.
>To unsubscribe from this group, send email to 
>excel-macros+unsubscr...@googlegroups.com.
> 
> 
>
>-- 
>Join official facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES (1120+ members already BANNED for violation)
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
> 
>2) Don't post a question in the thread of another member.
> 
>3) Don't post questions regarding breaking or bypassing any security measure.
> 
>4) Acknowledge the responses you receive, good or bad.
> 
>5) Cross-promotion of, or links to, forums competitive to this forum in 
>signatures are prohibited. 
>
> 
>6) Jobs posting is not allowed.
> 
>7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
> 
>NOTE : Don't ever post personal or confidential data in a workbook. Forum 
>owners 
>and members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To post to this group, send email to excel-macros@googlegroups.com.
>To unsubscribe from this group, send email to 
>excel-macros+unsubscr...@googlegroups.com.
> 
> 
>
-- 
Join official facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES (1120+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

 
6) Jobs posting is not allowed.
 
7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum 
owners 
and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.

-- 
Join official facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES (1120+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

6) Jobs posting is not allowed.

7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.


Reply via email to