I posted on here yesterday for help with code regarding my original problem "Problem with blocking a cell when it displays a certain values (VBA)" and received this code:
Private Sub Worksheet(ByVal Target As range)
If Target.Address = "D10:E10" Then
ThisWorkbook.Sheets("abc").Unprotect
Cells.Locked = True
If range("D10:E10") = "MM" Then
range("J14:K14").Locked = False
Else
range("J14:K14").Locked = True
End If
range("D10:E10").Locked = False
ThisWorkbook.Sheets("abc").Protect
End If
End Sub
This solved my original problem however I now want to apply this to 2 sets of 2 joined cells.
I want to be able to block 2 cells "J14:K14" to prevent users from accessing them when cells "D10:E10" display all options but "MM".
When it displays "MM" I want users to be able to access the cells.
""D10:E10"" are the cells containing the drop down list from which the user can select options: "a","b","c" and "MM". While "J14:K14" are the cells that I want to block access to when they are not displaying "MM". "D10:E10" is linked to "J14:K14", so that when "MM" is not selected in the drop down "D10:E10", cells "J14:K14" become hidden but can still be accessed by the user if they accidentally interact with what is meant to be a blank space.
Private Sub Worksheet(ByVal Target As range)
If Target.Address = "D10:E10" Then
ThisWorkbook.Sheets("abc").Unprotect
Cells.Locked = True
If range("D10:E10") = "MM" Then
range("J14:K14").Locked = False
Else
range("J14:K14").Locked = True
End If
range("D10:E10").Locked = False
ThisWorkbook.Sheets("abc").Protect
End If
End Sub
This solved my original problem however I now want to apply this to 2 sets of 2 joined cells.
I want to be able to block 2 cells "J14:K14" to prevent users from accessing them when cells "D10:E10" display all options but "MM".
When it displays "MM" I want users to be able to access the cells.
""D10:E10"" are the cells containing the drop down list from which the user can select options: "a","b","c" and "MM". While "J14:K14" are the cells that I want to block access to when they are not displaying "MM". "D10:E10" is linked to "J14:K14", so that when "MM" is not selected in the drop down "D10:E10", cells "J14:K14" become hidden but can still be accessed by the user if they accidentally interact with what is meant to be a blank space.
Last edited: