+ Reply to Thread
Results 1 to 12 of 12

Macro fails after sharing workbook

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Macro fails after sharing workbook

    G'Day All, I need some help from the masters please.

    Explanation:

    Worksheet "Sheet1" contains a listing of multiple addresses in columns containing "City" and "Street". This worksheet is protected to prevent users from changing the format,
    layout, etc; plus to protect command buttons used for navigation and initiating other macros.

    Worksheet "Sheet2" contains only temporary data (sourced from Sheet1) that is used as a lookup from a dropdown box.

    This macro performs the following:

    Sheet2 - cleared of all previous data
    Sheet1 - unprotect sheet to allow for next actions to take place
    Sheet1 - filters removed to ensure all data is displayed
    Sheet1 - sort data to incorporate any new entries added since last sort
    Sheet1 - because there are duplicate "cities" in the City column, the entries are filtered into unique values (to produce only one instance of each City), then copied to Sheet2.
    This filtered list now on Sheet2 is later referenced by a dropdown box, with the output being displayed on a Userform.
    Sheet1 - autofilter is restored and is protection turned back on

    Please Login or Register  to view this content.
    The macro works perfectly until the workbook is SHARED. Then it crashes due to the following:

    Sheet PROTECTION cannot be turned OFF and ON when in shared state
    The FILTERING to unique values cannot be performed when in shared state

    Question: Is there another way to do these actions so that everything works when the workbook is in a shared state?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Macro fails after sharing workbook

    Short story:no, not really.

    Limitations of shared workbooks:

    https://support.office.com/en-us/art...ID=HP010342985
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Macro fails after sharing workbook

    huumm, not good. I guess I can drop the sheet protection from the macro. Is there a way to at least lock down the command buttons on an unprotected sheet so that they do not get deleted or relocated by accident?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Macro fails after sharing workbook

    I've asked if anyone else has any ideas or suggestions but I wouldn't hold your breath.

    http://www.excelforum.com/showthread...=1#post4572230

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro fails after sharing workbook

    Quote Originally Posted by Rabbitoh View Post
    huumm, not good. I guess I can drop the sheet protection from the macro. Is there a way to at least lock down the command buttons on an unprotected sheet so that they do not get deleted or relocated by accident?
    Are individual users restricted to their own areas/sheets within the workbook or are they allowed to edit common areas?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Macro fails after sharing workbook

    Hi,

    Have you considered using a menu system in the Ribbon rather than buttons on worksheets for navigation? Or perhaps a floating userform?

    I should point out, just in case you are unaware, that most of the prominent Excel folk seem to regard shared workbooks as a really bad idea. Are you forced to use them?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Macro fails after sharing workbook

    Common areas for everyone

  8. #8
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Macro fails after sharing workbook

    An idea then, I can for-go the sheet protection, then could the following be a solution to the unique list problem:

    Create the unique list of Cities before sharing the workbook. Then scrap that part of the macro and instead use a COMPARE and COPY routine under the shared state to compare the contents of the "City" list in Sheet1, with the filtered unique list of Cities in Sheet2. If any new ones are found in the Sheet1 list then they get appended to the list is Sheet2. The Sheet2 list can then be sorted to produce the orderly list of Cities to display in the drop-down box. If so, what CODE would I need to achieve this??

    There doesn't seem to be anything on the Microsoft share prohibition list that says I can't do this!
    Last edited by Rabbitoh; 01-31-2017 at 04:06 PM. Reason: Spelling correction

  9. #9
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Macro fails after sharing workbook

    Ideally the share would be required to make it multi-user editable without having to wait until another user closes it.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Macro fails after sharing workbook

    When many users need to be able to access and update centralized data I've always preferred using a database (typically access in our case), while using a read-only spreadsheet that is only an interface, I load the data from the database on open, and data that needs adding or updating is done via macros either on buttons or userform objects/actions.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  11. #11
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Macro fails after sharing workbook

    I believe I have solved the problem of the unique value portion of my code that doesn't work in the SHARE state by adapting
    the "Compare" code provided elsewhere in the forum by Forum Contributor "cantosh" for user ncarrotine on 03-16-2016, 11:28 AM, under
    the title "macro to compare and clear cells in two columns"

    By first copying the non-static (changing) data on Sheet1, to the rows on the SAME COLUMN well BELOW the static data on Sheet2, I then run the Compare to separate out all the entries that do not appear on the Sheet2 list. I then SORT the entire range so that the new entries are incorporated and
    alphabetised into the one list. i have tested it in the SHARE state and it works!

    Here it is:


    Please Login or Register  to view this content.
    Thanks to all who assisted with this problem. In respect to the UNPROTECT-PROTECT issue in the SHARE state, I will leave that for now until I have either inspiration to find a way around it, or frustration and just remove protection all together.

  12. #12
    Registered User
    Join Date
    07-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Macro fails after sharing workbook

    An update on both issues rasied in this query:

    Firstly, I have found that my Command Buttons remain locked down in the SHARE state even without sheet protection being on because all macros and objects get locked anyway when SHARE is turned on.

    Secondly, the solution I posted above for creating a unique list of "Cities" worked fine for a small list but missed the mark when I tried with a large list. So to ensure Forum integrity of solutions, I am posting my second solution which works with large lists, and which also works when the workbook is in a SHARE state. This second solution not only also allows for new cities to be added, but also for cities no longer required to be removed, something I didn't consider with the previous code.

    Step 1 is to first create a baseline list of Cities on Sheet2 (from cell A2 down) from which the following code will compare with the active list on Sheet1, then update going forward.


    Please Login or Register  to view this content.
    Last edited by Rabbitoh; 02-02-2017 at 03:31 PM. Reason: relocate :cool:

+ 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: 4
    Last Post: 09-05-2015, 08:41 PM
  2. Workbook Sharing - Macro Troubleshooting
    By PY_ in forum Excel General
    Replies: 1
    Last Post: 08-22-2012, 01:28 PM
  3. [SOLVED] Consolidate macro then I get #REF formula error when sharing workbook
    By jjislas in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-22-2012, 12:37 AM
  4. Sharing workbook macro
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2009, 05:55 AM
  5. Sharing a Workbook
    By jennie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2006, 06:32 AM
  6. macro in copied workbook fails
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-22-2006, 09:10 AM
  7. [SOLVED] Sharing a workbook
    By Julia in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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