tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have this code that when run simply adds in to cell "H15" the words "Section locked" or "Section Unlocked" and hides/unhides one of two shapes "ulock1" or "Lock1"
now this works great but i want to use it on my entire sheet
so instead of just H15, it will work for H20, H50 Ect.
how this can happenis like this,
i have shapes in every cell i want the macro to run on,
so if the macro could somehow identify what the cell under the shape was we could use this to adjust the refences
so is theeere a way to say
instead of CLL = "H15"
CLL = the cell under the shaped clicked?
here my code
Thanks
Tony
I have this code that when run simply adds in to cell "H15" the words "Section locked" or "Section Unlocked" and hides/unhides one of two shapes "ulock1" or "Lock1"
now this works great but i want to use it on my entire sheet
so instead of just H15, it will work for H20, H50 Ect.
how this can happenis like this,
i have shapes in every cell i want the macro to run on,
so if the macro could somehow identify what the cell under the shape was we could use this to adjust the refences
so is theeere a way to say
instead of CLL = "H15"
CLL = the cell under the shaped clicked?
here my code
Thanks
Tony
VBA Code:
Sub Lock1()
Application.EnableEvents = False
Call AA_unProtect
CLL = "H15"
Unlocked = "ulock1"
Locked = "Lock1"
If ActiveSheet.Range(CLL).Value = "Section locked" Then
ActiveSheet.Shapes(Unlocked).Visible = msoFalse
ActiveSheet.Shapes(Locked).Visible = msoTrue
ActiveSheet.Range(CLL).Value = "Section Unlocked"
Else
ActiveSheet.Shapes(Unlocked).Visible = msoTrue
ActiveSheet.Shapes(Locked).Visible = msoFalse
ActiveSheet.Range(CLL).Value = "Section locked"
End If
AA_Protect
Application.EnableEvents = True
End Sub