Forum Discussion

Uguey's avatar
Uguey
Copper Contributor
Mar 17, 2020
Solved

Excel mandatory cell with dropdown menu

Hello everyone

 

I have basic information in let's say columns M, N and O.
In column P I have a dropdown menu consisting of 3 different names.

What I would like now ist

1) that if any data in columns M, N or O get changed, it has to be mandatory to select a different name in column P than the existing one.

2) Or that if any data in columns M, N or O get changed, a Msg box appears to remind the user that one has to select a different option in column P than the existing one, even if there is nothing yet in that cell.

Thank you very much in advance.
 

  • You can do this with a very small macro on the page itself:

     

    Private Sub worksheet_Change(ByVal target As Range)

    If Not Intersect(target, Range("M:O")) Is Nothing Then
    MsgBox ("You must now change the dropdown in column P")
    Else
    End If

    End Sub

     

    I have attached an example - press Alt F11 to open the VBA editor and see the code in situ.

3 Replies

  • Savia's avatar
    Savia
    Iron Contributor

    You can do this with a very small macro on the page itself:

     

    Private Sub worksheet_Change(ByVal target As Range)

    If Not Intersect(target, Range("M:O")) Is Nothing Then
    MsgBox ("You must now change the dropdown in column P")
    Else
    End If

    End Sub

     

    I have attached an example - press Alt F11 to open the VBA editor and see the code in situ.

    • Meredith_S's avatar
      Meredith_S
      Copper Contributor

      Savia I'm new to VBA, how can i just make the dropdown mandatory? this is a table where data entry is ongoing

    • Uguey's avatar
      Uguey
      Copper Contributor

      Top notch! Works like a charm.
      Thank you very much for your help.Savia 

Resources