ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Unprotect Cells depending on Cell value (https://www.excelbanter.com/excel-worksheet-functions/41411-unprotect-cells-depending-cell-value.html)

Abes

Unprotect Cells depending on Cell value
 
Hi,

I would like to know if I am able to protect and unprotect a range of cells
based on the date in another cell.
For example:
Cells N13:N22 are for a period between 21Aug and 23Aug and Cells N27:N37 are
for a period between 25 Aug and 27 Aug. Today's date would be in Cell A1.
I wish to be able to unprotect Cells N13:N22 when Cell A1's value is
equal/greater than to 21Aug and re-protect them on 24Aug.

Thanks in advance

-----------

Abes
Western Australia

sirknightly

Abes,

Use this macro (replace GT and LT with appropriate Greater Than and Less Than symbols) where values to be evaluated and protected are in column "N" and your start and end dates are in A1 and A2, respectively:

BEGIN MACRO
--------------------
Sub protectdate()

For Each Item In ActiveSheet.Range("N:N")
If Item.Value GT= Range("a1").Value And Item.Value LT= Range("a2").Value Then
Item.Locked = False
Else
Item.Locked = True
End If
Next

End Sub
--------------------
END MACRO

Knightly

Quote:

Originally Posted by Abes
Hi,

I would like to know if I am able to protect and unprotect a range of cells
based on the date in another cell.
For example:
Cells N13:N22 are for a period between 21Aug and 23Aug and Cells N27:N37 are
for a period between 25 Aug and 27 Aug. Today's date would be in Cell A1.
I wish to be able to unprotect Cells N13:N22 when Cell A1's value is
equal/greater than to 21Aug and re-protect them on 24Aug.

Thanks in advance

-----------

Abes
Western Australia


Abes

Sirknightly,
Thanks for the assistance, I will modify my spreadsheet to be able to
incorporate something along the lines of your suggestion.
--
Cheers

Abes


"sirknightly" wrote:


Abes,

Use this macro (replace GT and LT with appropriate Greater Than and
Less Than symbols) where values to be evaluated and protected are in
column "N" and your start and end dates are in A1 and A2,
respectively:

BEGIN MACRO
--------------------
Sub protectdate()

For Each Item In ActiveSheet.Range("N:N")
If Item.Value GT= Range("a1").Value And Item.Value LT=
Range("a2").Value Then
Item.Locked = False
Else
Item.Locked = True
End If
Next

End Sub
--------------------
END MACRO

Knightly

Abes Wrote:
Hi,

I would like to know if I am able to protect and unprotect a range of
cells
based on the date in another cell.
For example:
Cells N13:N22 are for a period between 21Aug and 23Aug and Cells
N27:N37 are
for a period between 25 Aug and 27 Aug. Today's date would be in Cell
A1.
I wish to be able to unprotect Cells N13:N22 when Cell A1's value is
equal/greater than to 21Aug and re-protect them on 24Aug.

Thanks in advance

-----------

Abes
Western Australia



--
sirknightly



All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com