is sheet protected?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i want to paint some cells in red if the activesheet is not protected
(conditional formatting)

ather question:
a vba code "if the activesheet is unprotected then...."

thank you
rozent
 
Hello ×¨×•×–× ×˜,

In VBA...
If ActiveSheet.ProtectionMode = True Then
ActiveSheet.Range(MyRange).Interior.ColorIndex = 3
End If

MyRange is the range you want to color red.

Sincerely,
Leith Ross
 
thank you
what about the first part of my question:
" i want to paint some cells in red if the activesheet is not protected
(by conditional formatting)" not vba

rozent
 
sory but it dosnt work
i tried this:

Sub if_protected()
On Error Resume Next
If ActiveSheet.ProtectionMode = True Then
'ActiveSheet.Range(MyRange).Interior.ColorIndex = 3
MsgBox "protected"
Exit Sub
Else
MsgBox "not protected"
End If
End Sub

i get all ways "not protected"

rozent
 
You can protect a few different things on a worksheet.

Dim wks as worksheet
set wks = activesheet

If wks.ProtectContents _
Or wks.ProtectDrawingObjects _
Or wks.ProtectScenarios Then
msgbox "It's protected"
Else
'do the work to add the conditional formatting
end if
 

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