QUESTION: I have a protected worksheet, with only one column "opened" for my co-workers to add data. Because of the protection, I had to add a macros for them to be able to do spell check. Now I need that worksheet to be "shared", but the spell check macros no longer runs.

How can I do spell check on a shared-protected-worksheet?

ANSWER: You'll have add the code to unlock the file first, do the spell check, and then relock it

---------- FOLLOW-UP ----------

QUESTION: This is the macros that I originally used on the protected worksheet:
Sub Check_Spelling()
ActiveSheet.Unprotect Password:="password"
Cells.CheckSpelling SpellLang:=1033
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True, Password:="password"
End Sub

How can I edit/modify it to be able to run it on the now SHARED-protected-worksheet?

ANSWER: Try this, this is about all I can offer since I don't work with shared workbooks.  Try GOOGLE if this does not help

Sub test()
 With ThisWorkbook
   If .MultiUserEditing Then
     .Application.DisplayAlerts = False
     MsgBox "Not shared"
     Exit Sub
   End If
   For s = 1 To .Sheets.Count
   Next s

   Cells.CheckSpelling SpellLang:=1033

   'For s = 1 To .Sheets.Count
    ' .Sheets(s).Protect
   'Next s

   ActiveSheet.Protect DrawingObjects:=True, _
   Contents:=True, Scenarios:=True, Password:="password"
   .SaveAs Filename:=ThisWorkbook.FullName, _
   '.Application.DisplayAlerts = True
 End With
End Sub

---------- FOLLOW-UP ----------

QUESTION: I had to modify line 12, to add {.Sheets(s).Unprotect Password:="password"}. After this minor fix, it ran perfectly.

Now -I don't know why- I'm having an issue; is telling me that there is a problem in the first line {Sub test()} The Microsoft Visual Basic's box says there is a compile error in hidden module. Can you tell me what this means? Is this something you can tell me how to fix?

Thanks for all the help you have given me so far!!!

This can be a whole host of issues so it will be time consuming to cover them all.  Your line 12 line of code, which is different than what I sent you, suggests to me that you are, or VBA, is trying to un-protect ALL workbooks, whether open and visible or not, but not sure without testing.  All add-ins are actually workbooks that EXCEL opens and are hidden and I suspect those workbook sheets are trying to be unlocked.

If the code ran OK after you made the change then that suggests to me that you did something else AFTER that and there's no way I could know what that is.  Not sure if there's anything more I could help with
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts




I can provide help with most all EXCEL questions and most all questions about writing EXCEL macros. I have been developing macros for about 10 years in EXCEL and have switched to it from Lotus 1-2-3 after about 10 years of writing macros in it. Typically, I will not write a macro for you unless it is very short because of all the details a macro has to know about to work every time and all the time are rarely provided. If I am not given ALL the details, circumstances, and situations then a "good" macro can not be written. Please understand that I do not know it all and will be the first to say so. As politely as possible, I don't write macros for people on this site who need one, want one, seem to imply that they need one, and/or seem to think I am expected to write one UNLESS they are very short, quick, and simple. 99% of all macros are more involved than what you think and rarely am I provided with enough specific and complete details to have the code work the first time and every time. This typically means too many follow-up emails, and subsequent macro changes due to lack of specific details, just to get those details so that the macro would work, all of which is on my own free time. The voice of experience from responding to many questions from people who ask me to write a macro for them from this site tells me this. I don't mean to come across as unhelpful but macros are usually very specific and without ALL of the specifics the macro I would write will not address all of your needs and the layout, location, formatting, conditions, etc. of your data and any related files the macro would have to work with. What seems like a simple task to you is almost always more involved than what you think to have the macro ALWAYS work in EVERY situation. If you have a macro you have already written and have a question about it then perhaps I could help with that. I am sure and hope you can and do understand.

©2016 About.com. All rights reserved.