+ Reply to Thread
Results 1 to 6 of 6

Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

  1. #1
    Registered User
    Join Date
    01-03-2014
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    3

    Unhappy Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

    Hello everyone,

    I am trying to disable saving until all mandatory cells are populated.
    a) Tested ctrl+s and clicking on the save button without results.
    b) Created a Private Sub that's triggering the error "Compile error: Expected End Sub" and it's highlighting Sub MandatoryFields()

    No idea what's wrong, not sure if it's a contradicting code that's making this happen. Tried several fixes without success... Please help!


    Please Login or Register  to view this content.
    Thank you in advance for your help!
    Last edited by Grex; 02-27-2017 at 07:39 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

    Please Login or Register  to view this content.
    You need to delete this line:

    Sub MandatoryFields()

    Also, for clarity and to comply with the Forum rules, please place your code between the hash marks # #

  3. #3
    Registered User
    Join Date
    01-03-2014
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

    Thank you, Logit.

    I deleted the line and it deleted the entire macro. I had named the macro "MandatoryFields", which is why I think that happened.

    Do I have to name the macro "Workbook_BeforeSave" for the code to work?

    Thanks again.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

    Please place your example code in the # # marks. In the QUICK REPLY screen there are menu tools you can select. Look for the hash mark and click it.
    You'll need to use EDIT POST on your posting #1 to do this.

    Your code needs to go in the ThisWorkbook module of your workbook.

    This macro module:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    is restricted to that portion of your workbook.

  5. #5
    Registered User
    Join Date
    01-03-2014
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

    It works! thank you!!!!

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Disable Saving Until All Mandatory Fields are Populated - Cant get it to work!!!

    You are welcome.

    Thank you for changing your original post.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Mandatory Fields and Closing/Saving Workbooks
    By JCRoessler14 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2016, 10:31 AM
  2. Make fields mandatory else pop up dialog box while saving
    By leopl9319 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-30-2016, 04:02 AM
  3. Mandatory field required message when user skips mandatory fields
    By Bharathi27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2013, 05:12 AM
  4. Mandatory Fields
    By i82 in forum Excel General
    Replies: 1
    Last Post: 09-13-2012, 05:13 AM
  5. Mandatory fields check before saving the file
    By sudheesh.e in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-20-2008, 12:11 AM
  6. Replies: 2
    Last Post: 02-27-2008, 01:17 PM
  7. Mandatory Fields
    By Libby in forum Excel General
    Replies: 0
    Last Post: 01-19-2005, 06:11 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1