+ Reply to Thread
Results 1 to 5 of 5

Required fields at BeforeClose

Hybrid View

hoachen Required fields at BeforeClose 07-15-2013, 10:42 AM
ragulduy Re: Required fields at... 07-15-2013, 10:53 AM
hoachen Re: Required fields at... 07-16-2013, 09:19 AM
ragulduy Re: Required fields at... 07-16-2013, 09:22 AM
hoachen Re: Required fields at... 07-16-2013, 09:59 AM
  1. #1
    Registered User
    Join Date
    01-28-2007
    Posts
    12

    Required fields at BeforeClose

    I have 10 columns and 5 are required fields. Right now I put all required fields if it check empty then pop-a message box. See code below

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim a As string
    Set a = Sheets("LUN Allocate").Range("A3")
    If a.Value = "" Then
    MsgBox "Pls Enter date in Column A3"
    a.Select
    GoTo cancelMe
    End If

    cancelMe:
    Cancel = True 'cancels the save event

    End Sub

    AND SO ON...

    This will check each field that are required, but if the user do not want to continue to fill the sheet. (filled out only 3 out of 5 required).there is no way for them to quite or exit the spreadsheet if they don't fill in all 5 required field. How can I implement to have a option for them to select in which they can CONTINUE the required filed or EXIT the spreadsheet before they filled in all required fields.

    I come across this function but it did not know how to implement the required fields were need to be filled.

    MSG1 = MsgBox("Please enter", vbYesNo)

    If MSG1 = vbYes Then
    MsgBox "Yes, I want to continue"
    GoTo cancelMe
    Else
    MsgBox "No, Exit now"
    End If
    Exit Sub

    cancelMe:
    Cancel = True 'cancels the save event

    End Sub


    Please advice!
    Thanks for you your help!

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Required fields at BeforeClose

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If Sheets("LUN Allocate").Range("A3").Value = "" Then If MsgBox("Cell A3 not filled in, are you sure you want to exit?", vbYesNo) = vbNo Then Cancel = True
    End Sub
    ?

  3. #3
    Registered User
    Join Date
    01-28-2007
    Posts
    12

    Re: Required fields at BeforeClose

    Thank you for modified the script. It will works, however, this script will loop through all required questions before exit/close. Can it be just asking all the required fields before close? like:

    Please fill in A3, B3, C3..., are you sure you want to to exit. If no, stay at the page and yes close the sheet.

    Thanks!

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Required fields at BeforeClose

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If Sheets("LUN Allocate").Range("A3").Value = "" Or _
        Sheets("LUN Allocate").Range("B3").Value = "" Or _
        Sheets("LUN Allocate").Range("C3").Value = "" Then _
        If MsgBox("Cell A3 not filled in, are you sure you want to exit?", vbYesNo) = vbNo _
        Then Cancel = True
    End Sub

  5. #5
    Registered User
    Join Date
    01-28-2007
    Posts
    12

    Re: Required fields at BeforeClose

    it is close!!! the msgbox now only tell cell A3 even though it different field that is empty.

+ 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. Required Fields
    By jmswebdesign in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2007, 07:19 PM
  2. Required Fields
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-29-2007, 01:52 AM
  3. Required fields
    By Brian Boguhn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2006, 01:55 PM
  4. Required fields with comments
    By Cathy Landry in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  5. Required fields
    By Emily in forum Excel General
    Replies: 1
    Last Post: 06-22-2005, 08:05 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