Forum Discussion

Yeshika44's avatar
Yeshika44
Copper Contributor
Aug 30, 2024
Solved

How to apply custom data validation that locks the cell as per the value in the other cell.

Hi there My question is related to the custom data validation that locks the cell as per the value in the other cell. I have two data columns (R4:R1000 and U4:U1000). My question is, if we enter “O...
  • m_tarler's avatar
    m_tarler
    Aug 31, 2024

    Yeshika44  here is an idea.  add this:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Locked Then
            If Target.Column = 21 Then
                MsgBox ("This cell is locked because this row is not ""Open"" ")
            Else
                MsgBox ("No data entry needed here")
            End If
            Cells(Target.Row, 18).Select
        End If
        
    End Sub

    it will give that prompt and then force the cursor back to the cell in column R.  If you prefer you could tweak it to another location 

    I also added a msgbox if they pick a cell in column U that is locked

     

Resources