Hi,
I need to disable certain cells based on time. I.e. if current date is in March,certain cells would be disabled. Similarly for April and October....
I would appreciate your help.
Hi,
I need to disable certain cells based on time. I.e. if current date is in March,certain cells would be disabled. Similarly for April and October....
I would appreciate your help.
First use Format Cells to unlock all/relevant cells on the sheet. Then protect the sheet (though the code below does this). This code will lock cells as the months go by:
[vba]Me.Protect userinterfaceonly:=True
Select Case Month(Date)
Case 4: Range("CertainCells").Locked = True 'April
Case 6: Range("JuneCells").Locked = True 'June
Case 8: Range("CertainOtherCells").Locked = True 'August
End Select
[/vba] but this code will lock only a certain range according to the month, but will unlock the others:
[vba]Me.Protect userinterfaceonly:=True
Range("CertainCells").Locked = Month(Date) = 4 'April
Range("JuneCells").Locked = Month(Date) = 6 'June
Range("CertainOtherCells").Locked = Month(Date) = 8 'August
[/vba]When this code is run is up to you - perhaps in a worksheet event, or a workbook_open event.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Thanks a lot