Sheet protection

K

Karen53

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
 
C

Clinton M James

Karen,

Have you tired sheets(MainPagepg).unprotect rather than just
mainPagepg.unprotect?

Regards,
Clint
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top