Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sheet protection
Hi,
My workbook is running. Now I'm trying to add my protection into the sheets. As a new item is added to the list on the main page, a new sheet is created by copying a template and placing the appropriate formulas to link the new sheet with the main page. I add the unprotect/protect and the routine gives me a 1004 error. When check my variable, it is correct. I have tried this without setting the worksheet and with setting the worksheet. I still get the same results. What baffles me is it works until I add the protection. Is there something I don't understand? I need to add the unprotect/protect in each routine, correct? here's my code: Sub SaveTenantName(Choice) Dim ws As Worksheet Set ws = MainPagepg MainPagepg.Unprotect (MyPassword) With ws 'save Tenants Name With Cells(Choice, 6) .NumberFormat = "General" .Value = frmStoreData.txtTenantName.Value End With End With MainPagepg.Protect ([MyPassword]), AllowFormattingCells:=True End Sub -- Thanks for your help. Karen53 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sheet protection
Karen,
Have you tired sheets(MainPagepg).unprotect rather than just mainPagepg.unprotect? Regards, Clint "Karen53" wrote in message ... Hi, My workbook is running. Now I'm trying to add my protection into the sheets. As a new item is added to the list on the main page, a new sheet is created by copying a template and placing the appropriate formulas to link the new sheet with the main page. I add the unprotect/protect and the routine gives me a 1004 error. When check my variable, it is correct. I have tried this without setting the worksheet and with setting the worksheet. I still get the same results. What baffles me is it works until I add the protection. Is there something I don't understand? I need to add the unprotect/protect in each routine, correct? here's my code: Sub SaveTenantName(Choice) Dim ws As Worksheet Set ws = MainPagepg MainPagepg.Unprotect (MyPassword) With ws 'save Tenants Name With Cells(Choice, 6) .NumberFormat = "General" .Value = frmStoreData.txtTenantName.Value End With End With MainPagepg.Protect ([MyPassword]), AllowFormattingCells:=True End Sub -- Thanks for your help. Karen53 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Data Protection Best Practice: AKA: Real Sheet Protection | Excel Discussion (Misc queries) | |||
Excel Data Protection- AKA: Sheet/Macro Password Protection | Setting up and Configuration of Excel | |||
Q about sheet protection | Excel Discussion (Misc queries) | |||
sheet protection | Excel Worksheet Functions | |||
Sheet protection error msg - Unrequested sheet activation | Excel Programming |