validating

  • Thread starter Thread starter adn4n
  • Start date Start date
A

adn4n

I have a cell named 'Start Date', theuser eneters the date and a list o
dates appear for that week, but i would like to validate this cell s
that the user cannot enter for example 29/04/2004 when it is 25/04/200
today, can anyone help me with this, many thanks
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
If .Value > Date Then
MsgBox "Date cannot be in the future"
.Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Don't know if I completely understand what you're looking for.

Do you want to restrict the cell entry to today?
If so, why a drop down box with choices of dates if only today will be
valid?
OR
Do you want the date to be *no later* then today?

To allow today *only*:
Select the cell, and then,
<Data> <Validation>,
In the "Allow" box, choose "Date",
In the "Data" box, choose "Equal To",
In the "Date" box enter
=TODAY()
Then <OK>.

To allow *no later* then today,
Just change the "Data" box to "Less Then Or Equal To".
 
With your date input cell active at the menu, Data, Validation..., Settings
Tab
Allow Box - Date
Data Box - Equal to
Date - Today()
OK
HTH
 

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