How to make a number of cells mandatory if another cell is populated?

MW_BAH

New Member
Joined
Apr 10, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi everyone - newbie to the forum here looking for some help

I have a sheet where I want to make certain cells in a row mandatory if a specific cell in the same row is not blank. For example, if B1 is not blank then cells C1, D1, E1 and M1 must be filled in. I would need this to apply to every row on the sheet and display an error message before save and close if any of the mandatory cells are blank, unless of course column 1 is blank. All cells would be free-type and not using drop downs.

I understand I can probably use VBA to do this but have no idea what code to use so would appreciate any advice and step by step guidance on how to do this.

Thanks!
 
Hi, sorry for delay in replying, for some reason our iCloud access froze and I didn't see any emails.

What has happened is that when the command
VBA Code:
Application.EnableEvents=false
has been executed and the 'End or Debug' message occurred the code didn't get to the matching
VBA Code:
Application.EnableEvents=True
.

In a code module put:

VBA Code:
Sub ResetMacro()
   Application.EnableEvents=True
End Sub

If you get the error again you can run that macro to restart the events handling.

When the 'End or Debug' message occurs can you select Debug and then take a screen shot of the code and line with the error. It is likely to be a conflict or error in sheet names or something similar.

HTH.
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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