What error are you getting? (I think I know the answer, but you should really have provided that with your question)
Ask yourself: What is "Contents"? What is "Scenarios"? I THINK, you'll find that "Contents = True" and "Scenarios = True" are intended to be part of the ActiveSheet.Protect statement. When I recorded a macro to protect a sheet, it resulted in: ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=False If you want to move them to different lines, you have to use the "continuation" character (_), like: ActiveSheet.Protect DrawingObjects:=True, _ Contents:=True, _ Scenarios:=False Paul ----------------------------------------- “Do all the good you can, By all the means you can, In all the ways you can, In all the places you can, At all the times you can, To all the people you can, As long as ever you can.” - John Wesley ----------------------------------------- ________________________________ From: Prabhu Pinky <prabhupin...@gmail.com> To: excel-macros@googlegroups.com Sent: Fri, May 17, 2013 7:56:56 AM Subject: Re: $$Excel-Macros$$ PROTECT EACH SHEET WITH MSG BOX. Hi experts, in the below code, am getting error on highlighted lines.. pls help Sub PROTECT_EACH_SHEET() ' Loop through all sheets in the workbook For i = 1 To Sheets.Count ' Activate each sheet in turn. Sheets(i).Activate response = MsgBox("Do you want to protect this sheet?", vbYesNo) If response = vbYes Then ActiveSheet.Protect.DrawingObjects = True Contents = True Scenarios = True ElseIf response = vbNo Then MsgBox ("Sheet not protected") End If Next i End Sub On 16 May 2013 19:35, DHAMODHARAN KARTHIKEYAN <deekart...@gmail.com> wrote: Dear Friend(s), > >SUB : PROTECT EACH SHEET WITH MSG BOX. > >I have a request on the following VBA Codes (this, I have collected from our >group or somewhere, I do not remember) : > >- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >- >- - >Sub PROTECT_EACH_SHEET() > > ' Loop through all sheets in the workbook > For i = 1 To Sheets.Count > > ' Activate each sheet in turn. > Sheets(i).Activate > > response = MsgBox("Do you want to protect this sheet?", vbYesNo) > If response = vbYes Then > ActiveSheet.PROTECT , DrawingObjects:=True, _ > Contents:=True, Scenarios:=True > > ElseIf response = vbNo Then > MsgBox ("Sheet not protected") > > End If > Next i > End Sub >- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >- >- - > >I expect the existing VBA Codes to further improve like ‘when I press ESC key, >it should stop, as the existing one goes till it reaches the last sheet’. > >As I have more than 50 sheets (having the collection of EXCEL MACROS VBA >CODES) >in my file, I look for STOP, if ESC key is pressed. > >Subject to your time, convenience and availability, you may do the needful. > >With Regards,DK.-- >Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >https://www.facebook.com/discussexcel > >FORUM RULES > >1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get >quick attention or may not be answered. >2) Don't post a question in the thread of another member. >3) Don't post questions regarding breaking or bypassing any security measure. >4) Acknowledge the responses you receive, good or bad. >5) Jobs posting is not allowed. >6) Sharing copyrighted material and their links is not allowed. > >NOTE : Don't ever post confidential data in a workbook. Forum owners and >members >are not responsible for any loss. >--- >You received this message because you are subscribed to the Google Groups "MS >EXCEL AND VBA MACROS" group. >To unsubscribe from this group and stop receiving emails from it, send an >email >to excel-macros+unsubscr...@googlegroups.com. >To post to this group, send email to excel-macros@googlegroups.com. >Visit this group at http://groups.google.com/group/excel-macros?hl=en. >For more options, visit https://groups.google.com/groups/opt_out. > > > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en. For more options, visit https://groups.google.com/groups/opt_out.