R
RGK
I have a VBA macro that has been working thus far, and I'm pretty sure it
worked after I added sheet protection, but suddenly I get errors on a
simple cell write.
I press a button, and a macro is supposed to do a few things including
write a number to an innocent enough looking cell.
The macro starts with:
If Worksheets(MySheet).ProtectionMode = True Then
Worksheets(MySheet).Unprotect
End If
And away it goes doing some stuff. Because of this annoying error, I put
a msgbox just before the troublesome line:
MsgBox "Protection status is: " & ActiveSheet.ProtectionMode
Then the line that causes the failure:
Worksheets(MySheet).Range(DBSZspot).Value = DBSize
and DBSize is just a simple one or two digit integer. It worked fine
until recently.
When I run it, the msg box tells me:
"Protection status is False"
And then the error:
"Runtime error 1004 - The cell or chart
you are trying to access is protected
and therefore s read only...."
and so on about protecting sheets.
Any ideas? If I turn off the protection before running, it runs fine
(still getting my debug message box that claims the "Protection status is
false")
How can the write fail due to protection, when the debug message clearly
shows that the code sees it as unprotected?
-Ross
worked after I added sheet protection, but suddenly I get errors on a
simple cell write.
I press a button, and a macro is supposed to do a few things including
write a number to an innocent enough looking cell.
The macro starts with:
If Worksheets(MySheet).ProtectionMode = True Then
Worksheets(MySheet).Unprotect
End If
And away it goes doing some stuff. Because of this annoying error, I put
a msgbox just before the troublesome line:
MsgBox "Protection status is: " & ActiveSheet.ProtectionMode
Then the line that causes the failure:
Worksheets(MySheet).Range(DBSZspot).Value = DBSize
and DBSize is just a simple one or two digit integer. It worked fine
until recently.
When I run it, the msg box tells me:
"Protection status is False"
And then the error:
"Runtime error 1004 - The cell or chart
you are trying to access is protected
and therefore s read only...."
and so on about protecting sheets.
Any ideas? If I turn off the protection before running, it runs fine
(still getting my debug message box that claims the "Protection status is
false")
How can the write fail due to protection, when the debug message clearly
shows that the code sees it as unprotected?
-Ross