ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   is sheet protected? (https://www.excelbanter.com/excel-programming/366057-sheet-protected.html)

רוזנט

is sheet protected?
 
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

Leith Ross[_619_]

is sheet protected?
 

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


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557637


רוזנט

is sheet protected?
 
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

"Leith Ross" wrote:


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


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557637



רוזנט

is sheet protected?
 
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

"Leith Ross" wrote:


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


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557637



Dave Peterson

is sheet protected?
 
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



????? wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com