Data Validation & Mandatory Cell

matty_lou82

New Member
Joined
Sep 14, 2018
Messages
38
Hi - I have created a drop down list (Column A), and in the adjacent column I need to make it mandatory for completion depending on a specific entry in column A (from the drop down list)

How can this be done? Is this facilitated via VBA code?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
It depends on what "completion" means. At what point in the user's process do you need to check to see if there is an entry in column B? Are there entries in other columns that you want to prevent until the user enters something in Column B? I think we need a more complete description of your process.

Normally mandatory fields apply to a form. You check for mandatory fields when the user clicks a Submit button. You can't check before that, because the user could be doing things in any order.
 
Upvote 0
Hi matty
This should fix your issue
Put this in the sheets code
This code will check if the user has changed row(selects a cell in another row) and if so will check that Bcolumn of the previous row is filled. if not then error and it puts the user back to that cell to complete. if it has a value it does nothing
VBA Code:
Dim cell As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not cell Is Nothing Then
    If Target.Row <> cell.Row Then
        If ActiveSheet.Cells(cell.Row, 2).Value = "" Then
            MsgBox "Column B must be filled out", vbCritical, "Error"
            ActiveSheet.Cells(cell.Row, 2).Select
        End If
    End If
End If
Set cell = Target
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top