+ Reply to Thread
Results 1 to 9 of 9

Make multiple fields required in form before save

Hybrid View

  1. #1
    Registered User
    Join Date
    02-28-2014
    Location
    Bay area
    MS-Off Ver
    Excel 2013
    Posts
    5

    Make multiple fields required in form before save

    Hi, I am trying to make multiple feild in a form required before the form can be save and sent back to me as an attachment. I am very new to this much of a detailed formula, any help would be greatly appriciated.

    The cells that I need to have required are E3, M3, R3, W3, E6, V6, E7, V7, V8, and E9

    Please help

    Thank you very much
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Make multiple fields required in form before save

    Try:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim c As Range, stErr As String
    For Each c In Range("E3, M3, R3, W3, E6, V6, E7, V7, V8, E9")
        If c.Value = "" Then stErr = stErr & c.Address & ", "
    Next c
    If stErr <> "" Then
        stErr = Left(stErr, Len(stErr) - 2)
        MsgBox "The following cells require user input:" & vbCr & vbCr & stErr, vbCritical + vbOKOnly, "Excel Forum"
        Cancel = True
    End If
    End Sub
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    02-28-2014
    Location
    Bay area
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Make multiple fields required in form before save

    This worked great, only problem is I need to be ablke to send a blank one out to my team. Is there a way to save it as a template so I can send it over blank and to do a "save as" they have to fill in everything?

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Make multiple fields required in form before save

    Interesting problem!!

    To save the blank template:

    In the visual basic editor, press Ctrl-G to view the immediates window.

    In the immediates window, type:
    Application.EnableEvents = False
    then press enter.

    Flick back to your workbook, and save it.
    Go back to the VBE, and in the immediates window, enter:
    Application.EnableEvents = True

    Sorted

  5. #5
    Registered User
    Join Date
    02-28-2014
    Location
    Bay area
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Make multiple fields required in form before save

    Hi, thank you for your help, I have tried this and I still cannot save a blank template that I can send out for folks to use.... any idea what micht be wrong?

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Make multiple fields required in form before save

    The method I described in post #4 should work.

    Attach the file, I'll save it as a blank template and attach it back.

  7. #7
    Registered User
    Join Date
    02-28-2014
    Location
    Bay area
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Make multiple fields required in form before save

    Thank you, I really appriciate it
    Attached Files Attached Files

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Make multiple fields required in form before save

    Try the attached.

    All I have done is exactly as I posted - opened your workbook, pasted the code into the ThisWorkbook module, disabled events, then saved. Please let me know how it works!
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-28-2014
    Location
    Bay area
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Make multiple fields required in form before save

    Thank you very much, it works wonderfully

+ 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. Replies: 0
    Last Post: 11-13-2012, 02:45 PM
  2. Macro that will make fields required
    By sarai77 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2012, 04:30 PM
  3. 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
  4. 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
  5. make a cell required to fill-in on form template
    By Jo in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-01-2005, 03:10 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