Is active cell editable?

X

XP

Using Office 2007 with Win XP;

I need to determine if the active cell is currently in an editable state. I
guess that really translates into whether or not it is locked AND sheet
protection is turned on? Is this all that needs to be tested?

Does anyone have efficient example code that might return true if
editable/false if not? If so, could you please post?

Thanks much in advance.
 
M

Mike H

Hi,

Try this. the message boxes are just for demonstration

Sub sonic()
If ActiveSheet.ProtectContents And ActiveCell.Locked Then
MsgBox "Locked"
Else
MsgBox "Unlocked"
End If

End Sub
Mike
 
T

The Code Cage Team

This should do what you need, just replace the message box with whatever
you want to happen!

Sub check_locked_cell()
With ActiveSheet
If ActiveSheet.ProtectContents = True And Selection.Locked = True Then
MsgBox "Activesheet is protected & Activecell is locked"
End If
End With
End Sub


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
 
Top