IF protection then skip sub.

M

mdma

i have an excel document, that works fine and produces another fil
based on the template.

On open of the original document, i have a macro to go and clear an
data in particular cells.

When creating the new file, in my macro I have set the new workbook t
be protected; however when this file is open, it goes and runs th
clear function. This gives an error as it can not clear the cell
due to the protection.

I dont want to turn the protection off, so is there anyway I can chec
for protection, if protection is found, then dont run the clear code,

Thanks
 
M

macropod

Hi mdma,

You could try something like:
If ActiveSheet.ProtectContents = True Then Exit Sub
or
If ActiveSheet.ProtectContents = False Then
' the rest of your clearing code goes here
End If

Cheers
 
Top