S
StargateFanFromWork
Sub YourMacro()
I am having so much trouble getting the syntax for this right. The above is
what can be done to unprotect a sheet then protect so that a macro can
complete its function. Since there are many sheets would really, really
like to have only one macro for them all, otherwise it's going to be a major
headache. Then there's the issue of using the code in other workbooks.
Unprotect/protect code that works on any sheet in any book would be a really
big help (I'd also use it on the other macros, too, so that buttons work
across the board.)
Also, none of my workbooks ever have a password. I protect them, yes, but
without one.
How can I make the above code work, then, pls?? Here's a sample of what the
it might look like, though the unprotect/protect parts are giving me errors.
ThisWorkbook.Worksheets("").Unprotect ("")
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ThisWorkbook.Worksheets("").Protect ("")
Thank you so very much!
ThisWorkbook.Worksheets("Sheet1).Unprotect("YourPassword")
'your code
ThisWorkbook.Worksheets("Sheet1).Protect("YourPassword")
End Sub
I am having so much trouble getting the syntax for this right. The above is
what can be done to unprotect a sheet then protect so that a macro can
complete its function. Since there are many sheets would really, really
like to have only one macro for them all, otherwise it's going to be a major
headache. Then there's the issue of using the code in other workbooks.
Unprotect/protect code that works on any sheet in any book would be a really
big help (I'd also use it on the other macros, too, so that buttons work
across the board.)
Also, none of my workbooks ever have a password. I protect them, yes, but
without one.
How can I make the above code work, then, pls?? Here's a sample of what the
it might look like, though the unprotect/protect parts are giving me errors.
ThisWorkbook.Worksheets("").Unprotect ("")
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ThisWorkbook.Worksheets("").Protect ("")
Thank you so very much!