Protection and hidden

  • Thread starter Thread starter Squid
  • Start date Start date
S

Squid

I have a worksheet where I formatted various cells to be
locked and others to be locked & hidden. I have code to
turn off protection so changes can be made, then
protection turned back on. The specified cells are
locked. But they are not hidden. What I am doing wrong?


TIA
Mike
 
if you turn protection off, then locked and hidden are ignored - they are
only in effect with protection turned on.
 
But at the end of the sub, I am turning the protection
back on. Even when the workbook opens the lock cells are
locked, but they are not hidden too. Here is one example
where I need to turn off protection so the spreadsheet
can update.

Private Sub cmbContracts_GotFocus()
'turn off protection so activesheet can update formulas
or values
ActiveSheet.Unprotect

End Sub

Private Sub cmbContracts_LostFocus()

Dim i As Integer 'Row
Dim j As Integer 'Code Column
Dim k As Integer 'Rate Column
Dim settle As Object
Set settle = Worksheets("Settlement")

'Starting Points
i = 30 'This will change
j = 14 'This column will stay constant
k = 8 'This column will stay constant

'Format Rates
For i = 30 To 46
If settle.Cells(i, j).Value = "G" Then
settle.Cells(i, k).NumberFormat = "0.000%"
Else
settle.Cells(i, k).NumberFormat = "$#0.000"
End If
Next i
ValidateDate
BenefitSummary

'turn on protection
settle.Protect

End Sub
 
I have never had a problem with it. If a cell is marked as hidden and
protection is on, I can't see the formula in the formula bar.
 

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

Back
Top