Mandatory Cells based on other column

lbutton

New Member
Joined
Jul 28, 2015
Messages
8
Hi All -

I am trying to make cells in a column mandatory based on the input of a different column.

If the user enters any input at all in column I, then the user must choose from the dropdown menu in column K before saving. However, if there is no input in column I, then nothing would be mandatory in column K.

For example, if the user puts, "Need to purchase new computer" in I6, then in K6, they need to be required to choose something from the dropdown already in place.

Thanks for your help! :)

I am using Excel 2010
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You might give this a try...

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim r As Range
Dim LastRow As Long

LastRow = Cells(Rows.Count, "I").End(xlUp).Row

For Each r In Range("I1:I" & LastRow)
    If r.Value <> "" And r.Offset(0, 2).Value = "" Then
        MsgBox "Please make a selection in Column K, Row " & r.Row
        Cancel = True
    End If
Next r

End Sub

Place the above code in the ThisWorkbook module, not a standard vba module.

Cheers,

tonyyy
 
Upvote 0
tonyyy -

I saved the excel as an Excel Macro-Enabled Workbook. When I closed it and then re-open it, at the top of the spreadsheet it has a message that says, "Security Warning Macros have been disabled." And then there is a button that says, "Enable Content". If the button is pressed, then everything works as it should, however if it is not pressed, people can type in column I, not make a selection in column K and save. I am afraid the users of this spreadsheet will not hit "Enable Content" before using.

Any thoughts?

Thanks!
 
Upvote 0
VBA can only do so much, and forcing users to enable content isn't one of them.

The best advice is to request, persuade, cajole, convince, bribe, demand, mandate, pout or somehow entice your users to enable macros and content.

Good luck!

tonyyy
 
Upvote 0
search

Thanks for your help tonyyy!
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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