+ Reply to Thread
Results 1 to 7 of 7

Looking for a macro to lock all cells ONLY when doc is read-only

  1. #1
    Registered User
    Join Date
    11-05-2010
    Location
    israel
    MS-Off Ver
    Excel 2003
    Posts
    32

    Looking for a macro to lock all cells ONLY when doc is read-only

    Hey you guys!

    I just made a database file using excel,
    This file is used by several users.

    I would like to create a macro that locks all cells to the users that are using the ifle in a "read-only" mode, but I can't figgure out hoew to do it,

    Kind regards!
    Thanks ahead.

  2. #2
    Registered User
    Join Date
    12-17-2010
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Looking for a macro to lock all cells ONLY when doc is read-only

    Could this be used with an event (e.g. thisworkbook_open)

    Please Login or Register  to view this content.

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

    Re: Looking for a macro to lock all cells ONLY when doc is read-only

    The above assumes no sheets to be protected in original state and all cells have default Locked status (and Macros are being enabled)

    Can you outline why you want to do this ? It could be that a "password to modify" would suffice ?

  4. #4
    Registered User
    Join Date
    11-05-2010
    Location
    israel
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Looking for a macro to lock all cells ONLY when doc is read-only

    Quote Originally Posted by DonkeyOte View Post
    The above assumes no sheets to be protected in original state and all cells have default Locked status (and Macros are being enabled)

    Can you outline why you want to do this ? It could be that a "password to modify" would suffice ?
    Well,
    When person "A" opens the file he can modify it and save it.
    But, when person "B" opens it, while "A" is using it, "B" it open as read-only file.
    Something a "read-only" user (e.g "B") forgets that and modifies it but then he can't save the changes.

    I want to lock it so "B" won't be able to modify at all.

    Thanks ahead!

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

    Re: Looking for a macro to lock all cells ONLY when doc is read-only

    If an end-user opts to make changes having been notified it's read only I suspect you have "bigger fish to fry".

    If needed you could generate an additional MsgBox that appears upon Open (in Read Only mode) that reiterates to end-user the fact that no changes made can be saved.

    If you really want to go down this route you need to also consider the possibility that Macros might not be enabled in the first instance which would make any subsequent coding moot.

    In reality you either need to:

    a) rely on end user intelligence in first instance

    or

    b) code the file such that when saved/closed in read-write mode it is "locked down" and is only "unlocked" if Macros are Enabled and the file is not in Read Only state
    (all by virtue of the Open event)

  6. #6
    Registered User
    Join Date
    11-05-2010
    Location
    israel
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Looking for a macro to lock all cells ONLY when doc is read-only

    Since I had few cells that should be locked for all users, I used perboeggild's code, with a little addition of mine,

    Check it out
    Please Login or Register  to view this content.
    Thank you all ~ SOLVED
    Last edited by Leith Ross; 12-19-2010 at 02:44 PM. Reason: Added Code Tags

  7. #7
    Forum Contributor
    Join Date
    11-04-2011
    Location
    pak
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Looking for a macro to lock all cells ONLY when doc is read-only

    hello, Natanz
    could u tell me how does it work. I tried but it did not show me the desired result. I want to lock some cell

    thanks

+ 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