+ Reply to Thread
Results 1 to 9 of 9

VBA Code to stop users Saving

  1. #1
    Registered User
    Join Date
    06-09-2010
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    VBA Code to stop users Saving

    Hi

    I have a simple spreadsheet and want to prevent people saving the spreadsheet if they havent completed certain cells. and if possible have the cursor take them to the cells they havent completed. (though that part not quite so vital)

    Can anyone help?

    Im a reasonable excel user but not good at VBA / Macros.

    Thanks

    D

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

    Re: VBA Code to stop users Saving

    This would go into the ThisWorkbook module..
    Please Login or Register  to view this content.

    Just edit the cells listed in the CheckRNG.
    Last edited by JBeaucaire; 06-10-2010 at 10:47 AM.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    06-09-2010
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA Code to stop users Saving

    Hi

    Thanks for the help but when I try and save I get the error message

    'Compile error: variable not defined'

    and it highlights the word 'cell' on the line of code

    'For Each cell In CheckRNG'

    Any ideas?
    D

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA Code to stop users Saving

    You should change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-09-2010
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA Code to stop users Saving

    Think thats done it! - Thank you both!

  6. #6
    Registered User
    Join Date
    06-09-2010
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA Code to stop users Saving

    Ive just thought of another issue! (sorry)

    I want to share this spreadsheet with other peopel on a shared drive location.

    When they open the form they will save it to their own PC's, complete the form and then email back to me. In effect my form is the template they need to complete a timesheet.

    In this scenario how do I ensure the form is saved with all fields blank in the shared location (for users to open and access), but after they have opened it up the Code I have just written initiates so that they must complete certain fields before saving? (they would then email me the completed form)

    In effect at the moment for me to save this spreadsheet to a certain location will mean I need to populate fields beforehand?

    Am i making sense and is it possible to save the spreadsheet with blank fields and only when they start filling it out themselves does the code initiate?

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VBA Code to stop users Saving

    Possibly this code
    Please Login or Register  to view this content.

    It's just a bit added to Jerrys' code

    Hope this helps

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

    Re: VBA Code to stop users Saving

    To save this form to a local drive with all fields blank, you could just click on the DESIGN MODE icon, then save the file. DESIGN MODE disables macros and should make it simple.

    DESIGN MODE is an icon on the Control Toolbox toolbar.


    Marcol's idea is nice too if you'd rather put the solution into VBA.

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VBA Code to stop users Saving

    Hmmm...

    Saving to a local drive using Design Mode means an unscrupulous user could part fill a form then post from there, mind you if there is a lot to fill in, and perhaps the user needs to wait for information, how else could they save and return later? In my experiance users would prefer to have that option.

    The save if all blank option still stands either way.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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