ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   unlock cell based on formula (https://www.excelbanter.com/excel-discussion-misc-queries/145776-unlock-cell-based-formula.html)

Huber57

unlock cell based on formula
 
I have a drop down menu titled "Reason" in Column A. Column B is protected
(locked). When the "other" seletion is made, I want to be able to unlock the
cell to the right so that someone can enter a reason. Can this be done with
either a formula or VBA?

Thanks!
huber57

Dave Peterson

unlock cell based on formula
 
Depends on how you made the dropdown and what version of excel you're using.

I'm gonna guess that you used Data|validation for the dropdown and you're not
using xl97.

If these are true, then right click on the worksheet tab that should have this
behavior and select view code. Then paste this code into the code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPWD As String

myPWD = "hi"

With Target
'one cell at a time
If .Cells.Count 1 Then Exit Sub
If Intersect(.Cells, Me.Range("a:a")) Is Nothing Then
'do nothing
Else
If .Value = "" Then
'do nothing
Else
Me.Unprotect Password:=myPWD
.Offset(0, 1).Locked = False
Me.Protect Password:=myPWD
End If
End If
End With

End Sub



Huber57 wrote:

I have a drop down menu titled "Reason" in Column A. Column B is protected
(locked). When the "other" seletion is made, I want to be able to unlock the
cell to the right so that someone can enter a reason. Can this be done with
either a formula or VBA?

Thanks!
huber57


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com