Set range for macro running

Closed
a_elgazar Posts 5 Registration date Thursday October 27, 2016 Status Member Last seen November 5, 2016 - Oct 27, 2016 at 08:03 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Oct 31, 2016 at 11:59 AM
if i have macro locked cells with change value of other cell , but this macro work from A1


i ask if i can modified code to let macro begin from row 9

this is my macro

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

ActiveSheet.Unprotect Password:=""

If Range("a" & Target.Row & ":a" & Target.Row).Value = 1 Then

Range("b" & Target.Row & ":b" & Target.Row).EntireColumn.Locked = True

Else
Range("b" & Target.Row & ":b" & Target.Row).EntireColumn.Locked = False


End If



ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Oct 27, 2016 at 10:58 AM
Hi a_elgazar,

Start your code with:
If Target.Row < 9 then exit sub

Best regards,
Trowa
0
a_elgazar Posts 5 Registration date Thursday October 27, 2016 Status Member Last seen November 5, 2016
Oct 27, 2016 at 01:37 PM
thanks sir

but still i have problem want ask you about it ;

if i have ( b2-d2) merged

when i try the previous code tell me

unable to set the locked property in the range class

do you have an idea to solve this problem
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Oct 31, 2016 at 11:59 AM
Hi a_elgazar,

For that you will have to unmerge first, then lock/unlock cells and then merge again.

If you can't write that part of the code, then let me know which cells are merged (i.e.B2-D2 for 100 rows).

Best regards,
Trowa
0