Worksheet protection different in 2010 from 2003?

User avatar
ErikJan
BronzeLounger
Posts: 1255
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Worksheet protection different in 2010 from 2003?

Post by ErikJan »

I have the statement:

.Protect Password:="", UserInterfaceOnly:=True

in the startup of my code. Then further down, I clean-up the sheet with this:

With Range("DataIn")
.Rows(1).Select
With .FormatConditions
.Delete

In Excel 2003 this worked (and works) no problems. In Excel 2010 I get an error on the ".Delete" statement. If I manually unprotect the sheet in the immediate window the code can be continued... So is there a difference or am I missing something very simple???

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Worksheet protection different in 2010 from 2003?

Post by HansV »

This appears to be a bug in Excel 2010. The workaround (as you undoubtedly know) is to unprotect the sheet, manipulate it, then protect it again.
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1255
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Worksheet protection different in 2010 from 2003?

Post by ErikJan »

Thank you.

Unbelievable... why do I always stumble on these things? I'm sure developers won't like this one... the 'UserInterfaceOnly' was pretty convenient at times.

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Worksheet protection different in 2010 from 2003?

Post by rory »

UserInterfaceOnly has never been reliable in my experience, especially with data validation, though I confess I haven't seen it error with conditional formats before.
Regards,
Rory