![]() |
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 |
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:
|
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