+ Reply to Thread
Results 1 to 5 of 5

Saving Restrictions

Hybrid View

ravi_m5_2000 Saving Restrictions 07-14-2009, 03:04 AM
royUK Re: Saving Restrictions 07-14-2009, 03:13 AM
JBeaucaire Re: Saving Restrictions 07-14-2009, 03:20 AM
ravi_m5_2000 Re: Saving Restrictions 07-14-2009, 04:07 AM
royUK Re: Saving Restrictions 07-14-2009, 04:48 AM
  1. #1
    Registered User
    Join Date
    03-23-2009
    Location
    Delhi
    MS-Off Ver
    Excel 2003
    Posts
    55

    Question Saving Restrictions

    Hi,

    I have one user form in Excel where, there are couple of fields which are mandatory to fill now what I want is, I want to restrict the user to save or system don't allow to save this Excel form till all the mandatory fields are filled.

    Please help me....!

    Regards,
    Ravi

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Saving Restrictions

    Presumably you have a Save button, use it's click event to check before saving
    Option Explicit
    
    Private Sub CommandButton1_Click()
        If Me.TextBox1.Value = Empty Or Me.TextBox2.Value = Empty Then
            MsgBox "You have not entered all necessary data", vbCritical, "Input required"
            Exit Sub
        End If
        'save code
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Saving Restrictions

    Like so, edit the message, sheet reference, ranges, etc, to your needs:

    Option Explicit
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    If Sheets("Sheet1").Range("A1") = 0 Then
        MsgBox "Sheet1 has a manadatory field in A1, please fill the correct value."
        Cancel = True
    End If
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    03-23-2009
    Location
    Delhi
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: Saving Restrictions

    Quote Originally Posted by JBeaucaire View Post
    Like so, edit the message, sheet reference, ranges, etc, to your needs:

    Option Explicit
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    If Sheets("Sheet1").Range("A1") = 0 Then
        MsgBox "Sheet1 has a manadatory field in A1, please fill the correct value."
        Cancel = True
    End If
    
    End Sub


    Thanks JB, Its working, --- GREAT

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Saving Restrictions

    You don't have a userform then!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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