Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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


good Protect Worksheet

Kutools for Excel's Protect Worksheet function can quickly protect multiple sheets or the whole workbook at once.
doc protect multiple worksheets

arrow blue right bubble Make a cell mandatory enter with VBA


Kutools for Excel, with more than 120 handy Excel functions, enhance your working efficiency and save your working time.

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

doc mandantory enter 1

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:
doc mandantory enter 2

Tip: You can change cell B1 to other cells you want.

doc download 1


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Akshay Patil · 7 days ago
    I want to make rows C2 to C7 mandatory and C13 to C19 mandatory?

    Any help?

    2 sets of ranges are here but under the same column.
  • To post as a guest, your comment is unpublished.
    ashwin kumar · 21 days ago
    I am enjoying playing this interesting puzzle game http://bejeweled3.co and found so entertaining Online and free game platform is this. Thanks for the awesome nice game.
  • To post as a guest, your comment is unpublished.
    Shea · 1 years ago
    Is there any way that I can Required cell f4 and F5 have data before closing or saving?
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Just change B1 to F4 and F5 in the textbox to remind users.
  • To post as a guest, your comment is unpublished.
    zwaenepoel · 1 years ago
    Hello, thank you for this formula, it works!

    However, now I have created a template in which several cells are mandatory to fill out. But after creating the template and entering the macro, I cannot close it, because I have to fill out the cells :) So, I cannot send out a template...(where the mandatory cells must still be empty)


    Can you help me?

    Thanks!
  • To post as a guest, your comment is unpublished.
    Shabaaz · 1 years ago
    Did you ever fined an answer to this?