Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works perfectly!
I'll be able to modify all my other custom buttons now using the basics of this code. Thank you! :oD "Tom Ogilvy" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protected/Unprotected Cells | Excel Discussion (Misc queries) | |||
Can a row containing protected & unprotected cells be copied? | Excel Worksheet Functions | |||
Unprotected cells becoming protected | Excel Programming | |||
Leave list box unprotected while protecting worksheet | Excel Discussion (Misc queries) | |||
Copy of protected document was unprotected in 97 and protected in 2002 | Excel Programming |