N
nesmith6866
I have one sub routines that is called from several locations in my VBA code;
sometimes the worksheet is already unprotected when the sub routine is called
and sometimes it is not. The problem is that my sub routine makes changes
to the sheet and reprotects. When this is called on by code that already
unprotected, then the sheet is protected after the routine is called and the
next line that edits the sheet crashes. I cannot remove the protect
statement from the sub routine, because it would occasionally cause the sheet
to remian unprotected. Is there a way for the sub routine to check to see if
the worksheet is protected so I can add an if statement to check this. if
the worksheet is protected when the sub routine is called, then it will
unprotect, make changes, and re-protect; if it is not protected, then it will
leave the sheet unprotected.
sometimes the worksheet is already unprotected when the sub routine is called
and sometimes it is not. The problem is that my sub routine makes changes
to the sheet and reprotects. When this is called on by code that already
unprotected, then the sheet is protected after the routine is called and the
next line that edits the sheet crashes. I cannot remove the protect
statement from the sub routine, because it would occasionally cause the sheet
to remian unprotected. Is there a way for the sub routine to check to see if
the worksheet is protected so I can add an if statement to check this. if
the worksheet is protected when the sub routine is called, then it will
unprotect, make changes, and re-protect; if it is not protected, then it will
leave the sheet unprotected.