Macro doesn't work when Sheets are protected UserInterfaceOnly

R

RyanH

I have a macro that deletes all conditonal formatting from several
worksheets. I set all worksheets protection UserInterfaceOnly:= True when
the workbook is opened. But when I run the macro below I get an Error:
Application-defined or object-defined error. If I unprotect the sheets it
works fine. I thought UserInterfaceOnly = True would allow all macros to
work. Anyone have any ideas?

Private Sub ClearDeptSchedules()

Dim wks As Worksheet
Dim lngLastRow As Long

For Each wks In colDepts
With wks
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
If lngLastRow >= 5 Then
.Rows("5:" & lngLastRow).Delete Shift:=xlUp
End If
ERROR>> .Cells.FormatConditions.Delete
.Range("H1") = Now
End With
Next wks

End Sub


Cheers,
Ryan
 
J

Jim Thomlinson

UserInterface only is very hit and miss as to what it allows a macro to do. I
personally don't use it. I protect and unprotect as required...
 

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

Top