How to make a particular cell mandatory enter before closing workbook?
When you share a workbook to other users for doing a survey which needs the real name registration, for instance, every user under investigation needs to enter their name in B1. But in some times, some users may close the workbook after investigation without entering their names. In this article, I introduce a VBA to make a particular cell mandatory before closing the workbook.
Make a cell mandatory enter with VBA
Make a cell mandatory enter with VBA
1. Enable the workbook that contains the mandatory cell, and press Alt + F11 keys to open Microsoft Visual Basic for Applications window.
2. In the Project pane, double click ThisWorkbook, and go to select Workbook and BeforeClose from right section list, then paste below code to the script. See screenshot:
VBA: Make a cell mandatory
If Cells(1, 2).Value = "" Then
MsgBox "Cell B1 requires user input", vbInformation, "Kutools for Excel"
Cancel = True
End If
3. Then save this code and close this popping window. Now, if the cell B1 is blank when you close the workbook, below dialog will pop out to remind you to enter something in B1. See screenshot:
Tip: You can change cell B1 to other cells you want.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
















