VBA to display error message if cells (A,B,C) are filled out, but cells (D,E,F) are not?

NiicckkM

New Member
Joined
Jul 9, 2015
Messages
28
I am creating a file that requires user-input. If the user begins to fill out the form, I want excel to display an error if they do not finish.

So if I need user input in cells A1, B1, C1, and D1, but the user only fills out A1,B1, and C1, I want excel to display a message saying "All Cells Must be filled. Please fill out cell D1".

This is what I've got so far

Code:
If IsEmpty(Range("A1").Value) = False And IsEmpty(Range("B1").Value) = False  And IsEmpty(Range("C1").Value) = False And IsEmpty(Range("D1").Value) = True  Then

MsgBox "All Cells Must be filled. Please fill out cell D1"
End if

End sub



The problem with this is that it will only display the message box if the sub is ran. I would like excel to automatically display this text. Also, is there a more efficient way to write that without so many And-Statements?

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I would think you need to create a UserForm. Any time you have a sheet event change the UserForm Pop's up. Put 4 text boxes on the UserForm and then when you click the OK button on the UserForm if you have not filled in all four text boxes you would get a popup alert.
With your wanting to have this automated without a UserForm how would the script know when you started filling in a form and when you had finished.
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

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