Try replacing it with: ActiveSheet.Protect , DrawingObjects:=True, _ Contents:=True, Scenarios:=True
OR ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True Whenever part of a syntax is appended in a second line, it is mandatory to end the first line with an underscore " _ " HTH On Fri, May 17, 2013 at 5:26 PM, Prabhu Pinky <prabhupin...@gmail.com>wrote: > *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.