+ Reply to Thread
Results 1 to 7 of 7

Need help with making fields required before save/print/close

  1. #1
    Registered User
    Join Date
    04-21-2015
    Location
    Florida, USA
    MS-Off Ver
    2010
    Posts
    20

    Need help with making fields required before save/print/close

    I have a form that has two tabs, Authorization and Final Reconciliation. I want to make several fields (b7:b12,h4,j7,m7,j8,m8,h9,h10) on the Authorization tab required before the user can save, print or close the form. Is there a way to do this??

    I have attached the spreadsheet for a better visual.

    Out of Area Travel Form Effective 2016-01-01.xlsm

    Thanks in Advance for any help

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,846

    Re: Need help with making fields required before save/print/close

    Place the following macros in the code module for ThisWorkbook. Do the following: Hold down the ALT key and press the F11 key. This will open the Visual Basic Editor. In the left hand pane, doubleclick 'ThisWorkbook'. An empty code window will open up. Copy and paste all three macros into the open window. Close the window to return to your sheet. When you attempt to save, close or print the form, you will be prompted to enter any missing information.
    Please Login or Register  to view this content.
    Last edited by Mumps1; 01-06-2016 at 01:36 PM.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Need help with making fields required before save/print/close

    Hi tnsvolley,

    See the attached sample copy of your file. You need the following code in the 'ThisWorkbook' code module of your file.
    Please Login or Register  to view this content.

    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    If you need help with Macros and/or VBA the following may help:
    To enable Macros and to Run Macros see the following:
    http://office.microsoft.com/en-us/ex...010031071.aspx
    http://office.microsoft.com/en-us/ex...010014113.aspx
    If help is still needed do a google search for 'youtube excel enable macro' and/or 'youtube excel run macro'.

    To access Visual Basic (VBA) see:
    http://www.ablebits.com/office-addin...a-macro-excel/
    a. Click on any cell in the Excel Spreadsheet (may not be needed).
    b. ALT-F11 to get to VBA.
    c. CTRL-R to get project explorer (if it isn't already showing).
    d. Double Click on a 'Module Name' in 'Project Explorer' to see code for that module.

    Lewis

  4. #4
    Registered User
    Join Date
    04-21-2015
    Location
    Florida, USA
    MS-Off Ver
    2010
    Posts
    20

    Re: Need help with making fields required before save/print/close

    Quote Originally Posted by LJMetzger View Post
    Hi tnsvolley,

    See the attached sample copy of your file. You need the following code in the 'ThisWorkbook' code module of your file.
    Please Login or Register  to view this content.

    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    If you need help with Macros and/or VBA the following may help:
    To enable Macros and to Run Macros see the following:
    http://office.microsoft.com/en-us/ex...010031071.aspx
    http://office.microsoft.com/en-us/ex...010014113.aspx
    If help is still needed do a google search for 'youtube excel enable macro' and/or 'youtube excel run macro'.

    To access Visual Basic (VBA) see:
    http://www.ablebits.com/office-addin...a-macro-excel/
    a. Click on any cell in the Excel Spreadsheet (may not be needed).
    b. ALT-F11 to get to VBA.
    c. CTRL-R to get project explorer (if it isn't already showing).
    d. Double Click on a 'Module Name' in 'Project Explorer' to see code for that module.

    Lewis
    Thank you, that worked perfectly!
    Eileen

  5. #5
    Registered User
    Join Date
    04-21-2015
    Location
    Florida, USA
    MS-Off Ver
    2010
    Posts
    20

    Re: Need help with making fields required before save/print/close

    Quote Originally Posted by LJMetzger View Post
    Hi tnsvolley,

    See the attached sample copy of your file. You need the following code in the 'ThisWorkbook' code module of your file.
    Please Login or Register  to view this content.

    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    If you need help with Macros and/or VBA the following may help:
    To enable Macros and to Run Macros see the following:
    http://office.microsoft.com/en-us/ex...010031071.aspx
    http://office.microsoft.com/en-us/ex...010014113.aspx
    If help is still needed do a google search for 'youtube excel enable macro' and/or 'youtube excel run macro'.

    To access Visual Basic (VBA) see:
    http://www.ablebits.com/office-addin...a-macro-excel/
    a. Click on any cell in the Excel Spreadsheet (may not be needed).
    b. ALT-F11 to get to VBA.
    c. CTRL-R to get project explorer (if it isn't already showing).
    d. Double Click on a 'Module Name' in 'Project Explorer' to see code for that module.

    Lewis
    That worked how I wanted, however, i did not think my plan through as now I can not save it as a blank form for others to fill in because the fields have to be filled in. Any ideas??

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Need help with making fields required before save/print/close

    Hi,

    You don't have to quote entire previous posts when replying.

    See the attached file that contains the following code. New Code and Modified Code are in red.

    To implement the code, Double Click cell 'A1' (to save), 'B1' (to print), 'C1' (to close) on sheet 'Authorization' and enter password abc (Case Insensitive). This will allow the 'Administrator' to save, print, or close the file at any time.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-21-2015
    Location
    Florida, USA
    MS-Off Ver
    2010
    Posts
    20

    Re: Need help with making fields required before save/print/close

    Wow...that is awesome...thanks so much!!!

+ 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. Make multiple fields required in form before save
    By tclemente in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-03-2014, 12:34 PM
  2. Create watermark, save as pdf, print pdf, close file**
    By noobtron in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 06:26 PM
  3. [SOLVED] Combine DocumentBeforeSave and Print (Required fields)
    By Marco-Kun in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2012, 06:30 AM
  4. Macro-Verify required fields before proceding with routine (save)
    By pjbassdc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-13-2012, 01:48 AM
  5. Won't Save if Required Fields are not Filled out
    By bronkista in forum Excel General
    Replies: 1
    Last Post: 07-29-2011, 04:10 PM
  6. Copy,Save,Print then Close
    By Geordie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-11-2010, 01:48 AM
  7. want to save, print and close wb
    By sakung in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2006, 06:26 AM
  8. [SOLVED] I like to open a folder,auto print,save then close
    By tied of opening files in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2005, 06:06 PM

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