excel - Unhide worksheet within a macro does not work when workbook is protected -


i have issue unprotecting / protecting sheet when run macro. read few posts stating should insert activesheet.unprotect password:="my password" bit before , activesheet.unprotect password:="my password", macro, has not worked. suggestions gratefully appreciated.

activesheet.unprotect password:="my password" sheets("sheet1").select sheets("sheet2").visible = true sheets("sheet2").select cells.select selection.copy workbooks.add cells.select activesheet.paste application.cutcopymode = false selection.copy selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _     :=false, transpose:=false application.cutcopymode = false range("a1").select application.displayalerts = false activeworkbook.saveas filename:="c:\file.csv" _     , fileformat:=xlcsv, createbackup:=false application.displayalerts = true application.displayalerts = false activeworkbook.save application.displayalerts = true application.displayalerts = false activewindow.close application.displayalerts = true sheets("sheet2").select activewindow.selectedsheets.visible = false sheets("sheet1").select activesheet.protect password:="my password" 


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -