Re-protect if originally protected, leave unprotected if not?
Assuming if anything on the sheet is protected, it will include content
protection.
Sub FillDownWithNumberSeries()
'
Dim bProtected as Boolean
bProtected = False
if activesheet.ProtectContents then
bProtected = True
ActiveSheet.Unprotect
end if
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
if bProtected then
Activesheet.Protect
end if
End Sub
--
Regards,
Tom Ogilvy
"StargateFanFromWork" wrote in message
...
I have this in my personal.xls for a button on one of my toolbars:
Sub FillDownWithNumberSeries()
'
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
End Sub
It's worked very well until now because I have never had protected sheets.
Now I have difficulty using if workbook is protected and am getting a
little
tired of unprotecting all the time <g. I've looked in the archives and
have found example code, but I'm not good at all on the ones dealing with
IF
statements yet so have not yet had success in modifying the code above to
fit this situation.
To put at the beginning of the above "ActiveSheet.Unprotect" is not a
problem as this will work in all cases, I imagine, whether protected or
not
(?). What I'm stuck on is for XL2K to re-protect (i.e., via something
like
"ActiveSheet.Protect") only those workbooks and sheets that were protected
to begin with. How would one do this, pls?
Thank you! :oD
|