+ Reply to Thread
Results 1 to 6 of 6

How to make a cell required before the user saves it

  1. #1
    Registered User
    Join Date
    11-20-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    How to make a cell required before the user saves it

    Hey guys...I have tried the following VBA code but its not working for some reason. I want cells J97:J99 required before the user can save it. The following code is what I tried:

    Private Sub Workbook_BeforeSave(Cancel As Boolean)
    If BusinessCase.Range("J97:J99").Value = "" Then
    MsgBox "Cannot save until cells J97:J99 have been completed!"
    Cancel = True
    End If
    End Sub


    Let me know what I did wrong. I've attached the file as well. Q12013 Project Planning Template.xlsm

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

    Re: How to make a cell required before the user saves it

    I can see a few issues that will create a problem. First of all, you have the code as part of the worksheet. It should be in the code window for ThisWorkbook. Also you are using merged cells which can create problems. As well, J99 is merged with H99 so when you click on J99 you will notice that it reads as H99. The line:
    Please Login or Register  to view this content.
    should read:

    Please Login or Register  to view this content.
    Try correcrting these problems first and see if that helps.
    Last edited by Mumps1; 01-03-2013 at 04:02 PM.

  3. #3
    Registered User
    Join Date
    11-20-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to make a cell required before the user saves it

    Thanks for the quick response, Mumps. I unmerged the cells and added the code in the ThisWorkbook window and I received the following error message:

    Compile Error: Procedure declaration does not match description of event or procedure having the same name.

    Any suggestions?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,097

    Re: How to make a cell required before the user saves it

    Try this code in ThisWorkbook:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-20-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to make a cell required before the user saves it

    That worked! Thanks again for your help!

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,097

    Re: How to make a cell required before the user saves it

    Glad it worked out.

+ 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