Unlock cell based on location of active cell

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
417
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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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