Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Cells unlocked then locked when worksheet activated

Folks,
In the attached workbook are two worksheets:
MonthlyTodayFindBirthdays
Sheet2
In the worksheet labeled "MonthlyTodayFindBirthdays" range L3:M14 and cell O2 are not locked.
When I protect the worksheet "MonthlyTodayFindBirthdays" I protect the worksheet as follows:
"Checked Select unlocked cells"
"Checked Format cells"
and then password protect the worksheet (password is 123memphis)
After protecting the worksheet I select the cells protected and unprotected and everything works fine. I have not left the worksheet.
However, when I select "sheet2" and return and activate "MonthlyTodayFindBirthdays" cells L3:M14 and O2 are now locked.
In looking at the Worksheeet.Activate I need to do some housekeeping in the "Practice" section. Maybe that's what's causing my cells to go from unlocked to locked?
Locked-cells.xlsm
0
Frank Freese
Asked:
Frank Freese
  • 3
  • 2
2 Solutions
 
Harry LeeCommented:
fh_freese,

What cause your sheet to relock itself is

Worksheets("MonthTodayFindBirthdays").Range("L3:M14").Clear

Open in new window


Clear will clear all the formats, including the toggle of Locked and Unlocked.

Is there any reason for you to clear the cells, then set the format up again?

If not, why don't you use
Worksheets("MonthTodayFindBirthdays").Range("L3:M14").ClearContents

Open in new window

so that the content is removed but the format remains?
0
 
Harry LeeCommented:
If you really need to clear the cells then reestablish all the formats and borders, add the following to the end of your code.

Worksheets("MonthTodayFindBirthdays").Unprotect password:="123memphis"
Worksheets("MonthTodayFindBirthdays").Range("L3:M14").Locked = False
Worksheets("MonthTodayFindBirthdays").Protect password:="123memphis"

Open in new window

0
 
Frank FreeseAuthor Commented:
Harry,
The reason for clearing the data in the range where the user can practice is that if I don't and they return to the Main Menu, the information they were working on is still there. When they return to the worksheet I want the worksheet to be "clean" - does this make sense to you?
I see what you are doing and the same thing crossed my mind. I just did not know it was possible.
I'll play around with it tonight after I get home and get back with you.
Thanks for the explanation - I did not know that about Clear but it makes sense now.
Frank
0
 
Frank FreeseAuthor Commented:
thanks...I "think" I've got it, but not sure yet how to implement your suggestion. I'll repost if I need more help
Appreciate it!
0
 
Harry LeeCommented:
Anytime.

I'm glad I can help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now