Unlock cell based on location of active cell

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
407
Office Version
  1. 2007
Platform
  1. Windows
I’m not sure I want to do this but I’d like to try it. I am looking for some VBA routine that unprotects a cell based on the location of the active cell.

All cells in Column H are locked. If the active cell is in column M, I want the corresponding row/cell in Column H to become “unlocked”. If I move the active cell to some other column other than M then all cells in column H again become locked.

Example: if the active cell is M44, then I want H44 to become “unlocked”. If I cursor down to cell M45, then H44 becomes locked and H45 becomes unlocked. If the active cell is B3 then all cells in column H remain locked.
 
Here is a video showing the error.
I've no doubts that you're experiencing an error Steve - my point is that I don't experience it when I use the file. I don't thin there's much more I can do for you on this one Steve, but if I could make one recommendation to improve your existing code, then change these:
VBA Code:
Sub UnProtect_It()
    Sheets("Amortize").Select
    ActiveSheet.Unprotect
End Sub
Sub Protect_It()
    Sheets("Amortize").Select
    ActiveSheet.Protect
End Sub
To this:

VBA Code:
Sub UnProtect_It()
    Sheets("Amortize").Unprotect
End Sub
Sub Protect_It()
    Sheets("Amortize").Protect
End Sub

ActiveSheet is a nightmare waiting to happen...
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I've no doubts that you're experiencing an error Steve - my point is that I don't experience it when I use the file. I don't thin there's much more I can do for you on this one Steve, but if I could make one recommendation to improve your existing code, then change these:
VBA Code:
Sub UnProtect_It()
    Sheets("Amortize").Select
    ActiveSheet.Unprotect
End Sub
Sub Protect_It()
    Sheets("Amortize").Select
    ActiveSheet.Protect
End Sub
To this:

VBA Code:
Sub UnProtect_It()
    Sheets("Amortize").Unprotect
End Sub
Sub Protect_It()
    Sheets("Amortize").Protect
End Sub

ActiveSheet is a nightmare waiting to happen...

I totally understand what you are saying and I must say again that I most sincerely appreciate your time, concern, and assistance with this.

Again, my thanks,
Steve K.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top