+ Reply to Thread
Results 1 to 6 of 6

VBA - Locking sheet for editing with macro

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    Laval quebec
    MS-Off Ver
    Excel 2007
    Posts
    93

    VBA - Locking sheet for editing with macro

    Hi team,

    I have a little userform that is used to gather information about some orders...What it does is lets the user enter all information and all this info gets copied to a sheet... I would like to be able to actually not let anyone be able to edit the data once it's been copied... In the past I had tried locking the cells and protecting the sheet but this caused me many errors with the macro as it wasn'T able to write... Any ideas on how I can encounter this or what my options are here..

    Thanks team!

  2. #2
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: VBA - Locking sheet for editing with macro

    Hi DJ,

    mu suggestion would be.

    Before you run the macro, add below code
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and once the macro finished, add below code:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Cheers
    Lex

  3. #3
    Registered User
    Join Date
    01-15-2014
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA - Locking sheet for editing with macro

    I've been looking for this too. This works great. Thanks, all.

  4. #4
    Registered User
    Join Date
    08-22-2011
    Location
    Laval quebec
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA - Locking sheet for editing with macro

    Hi Lexusap,

    Thank you ! It works BUT once I make the file a shared file (Which is what I need as many users use this file at the same time).. I get an error : Unprotect method of worksheet class failed... Runtime error 1004

  5. #5
    Registered User
    Join Date
    08-22-2011
    Location
    Laval quebec
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA - Locking sheet for editing with macro

    Hey I actually found a solution to my question..Tell me if I'm doing this right...Will the fact that i'm temporarily disabling sharing the file for a few seconds cause any issues?

    I first de-activated the sharing feature
    Please Login or Register  to view this content.
    Then I un-protect my sheet
    Please Login or Register  to view this content.

    Then Add this in the end:
    Please Login or Register  to view this content.



    I also added this to remove all the annoying display alerts I was getting for unsharing and sharing file:
    Please Login or Register  to view this content.
    at the bigging

    and

    Please Login or Register  to view this content.
    at the end

  6. #6
    Registered User
    Join Date
    08-22-2011
    Location
    Laval quebec
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA - Locking sheet for editing with macro

    Hey Team...Following my previous post I tried it on 2 differenct pcs and when I cam back to my first pc to try to enter another entry..I got an error the file is no longer shared...Any help on this one ?

+ 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: 1
    Last Post: 06-21-2012, 07:07 AM
  2. Locking Sheet based on Cell Value for a Macro
    By nalgene5622 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2012, 10:26 AM
  3. Locking ActiveX textbox from editing
    By 79p930 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-25-2011, 07:50 PM
  4. Locking and Editing Cells
    By jmozulay in forum Excel General
    Replies: 0
    Last Post: 10-19-2007, 08:40 AM
  5. Excel 2003 not locking speadsheet for editing
    By webbmeister in forum Excel General
    Replies: 0
    Last Post: 06-19-2007, 06:00 AM

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