I have the following VBA to build for a worksheet which by default is protected.
For the following event VBA should be looking for values in specific cells and unprotect related cell:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Case 1
If cell “U10” is 0 then cells “B19”, “B21”, “B23”, “B25”, “B27” and “R19”, “R21”, “R23”, “R25”, “R27”
Should be locked.
Case 2
If cell “U10” > 0 then cells “B19”, and “R19”, should be unlocked
cells “B21”, “B23”, “B25”, “B27” and “R21”, “R23”, “R25”, “R27” should remain locked
Case 3
If cell “U10” > 0
then
cells “B19”, and “R19”, should be unlocked
then
if cell “R19” value <1
then
cells “B21”, and “R21”, should be unlocked
cells “B23”, “B25”, “B27” and “R23”, “R25”, “R27” should remain locked
Case 4
If cell “U10” > 0
then
cells “B19”, and “R19”, should be unlocked
then
if cell “R19” value <1 and cell value “R21” <1 and cell “R21” value + cell “R19”value <1
then
cells “B23”, and “R23”, should be unlocked
cells “B25”, “B27” and “R25”, “R27” should remain locked
etc
I know “target” and/or “intersect” and/or “case” functions should be used, but unfortunately did not manage to get result.
Hoping to find swift support in this matter. Any help is highly appreciated
Thanks and regards
For the following event VBA should be looking for values in specific cells and unprotect related cell:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Case 1
If cell “U10” is 0 then cells “B19”, “B21”, “B23”, “B25”, “B27” and “R19”, “R21”, “R23”, “R25”, “R27”
Should be locked.
Case 2
If cell “U10” > 0 then cells “B19”, and “R19”, should be unlocked
cells “B21”, “B23”, “B25”, “B27” and “R21”, “R23”, “R25”, “R27” should remain locked
Case 3
If cell “U10” > 0
then
cells “B19”, and “R19”, should be unlocked
then
if cell “R19” value <1
then
cells “B21”, and “R21”, should be unlocked
cells “B23”, “B25”, “B27” and “R23”, “R25”, “R27” should remain locked
Case 4
If cell “U10” > 0
then
cells “B19”, and “R19”, should be unlocked
then
if cell “R19” value <1 and cell value “R21” <1 and cell “R21” value + cell “R19”value <1
then
cells “B23”, and “R23”, should be unlocked
cells “B25”, “B27” and “R25”, “R27” should remain locked
etc
I know “target” and/or “intersect” and/or “case” functions should be used, but unfortunately did not manage to get result.
Hoping to find swift support in this matter. Any help is highly appreciated
Thanks and regards