If Function Question

  • Thread starter Thread starter Damil4real
  • Start date Start date
D

Damil4real

I have a listbox in cell a15 with a Yes & No. If user picks "yes",
lock cell a16 because the question will not be applicable, and I don't
want the user to choose any option.

How do I do that in excel?

Thanks!
 
Damil,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

Your worksheet should be protected, with a password - the password assumed below can be changed.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
Const PW As String = "Password"
If Target.Address <> "$A$15" Then Exit Sub
With Target.Offset(1, 0)
Target.Parent.Unprotect PW
If Target.Value = "No" Then
.Locked = True
.Interior.ColorIndex = 3
Else
.Locked = False
.Interior.ColorIndex = xlNone
End If
End With
Target.Parent.Protect PW
End Sub
 
You can't lock a cell with a formula (and the sheet would need to be
protected anyway, for it to have any effect), but what you might want
to do is apply conditional formatting to cell A16 so that the
foreground colour is changed to white if A15 ="Yes", so it appears as
if no question is being asked.

Hope this helps.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Simple Formula Excel 2003 4
Text in formula? 8
Format Cells? 2
macro to determine if cell is blank 6
Average- Expanding column length 2
Sum on horizontal lookup. 2
range of unique cells 6
Data Compare 1

Back
Top