Using VBA to time protect ranges

  • Thread starter Thread starter don
  • Start date Start date
D

don

Hi hope you can help. Is it possible to use VBA to protect cells based
on the current date. I am wanting to stop information from being
changed that would belong to a past event ie I worked on Monday when I
didn't

Regards

Don
 
This is probably not the most elequent way to go about this but it does
do what you are looking for.


Sub Check_Date()
Dim Today, check
Today = Now ' Assign current system date and time.
check = Range("D4:D4").Value 'Selects cells to check for date
criteria
If check < Today Then 'Verify if date is older
Range("D4:D4").Select
Selection.Locked = True 'Lock cell if older. If not do
nothing.
End If
End Sub


Hope it helps
 
goober said:
This is probably not the most elequent way to go about this but it does
do what you are looking for.


Sub Check_Date()
Dim Today, check
Today = Now ' Assign current system date and time.
check = Range("D4:D4").Value 'Selects cells to check for date
criteria
If check < Today Then 'Verify if date is older
Range("D4:D4").Select
Selection.Locked = True 'Lock cell if older. If not do
nothing.
End If
End Sub


Hope it helps
Many thanks I will give it a go.

Regards

Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top