Validation issue

  • Thread starter Thread starter Insp Gadget
  • Start date Start date
I

Insp Gadget

Hi all,

What I'm trying to do is validate a single cell to ensure that the date is
greater than todays date. The cell in question has a calendar that pops up
when you select it and this is how the date for that cell is selected.
unfortuantely this means that the normal method of performing this
validation doesn't work. My calendar code is in 'Sheet1' is this the best
place for this new code?

Currently I get a: Run-time error '1004'
'Method Range' of object'_Worksheet' failed

Here is what I have so far.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Opens the calendar form
addr = ActiveCell.Address
If addr = "$G$38" Or addr = "$K$38" Then
Call OpenCalendar
End If
'Checks that the date selected is valid
If Range(G38) < Date Then
MsgBox "The date that you entered is in the past!"
Cancel = True
End If
End Sub


I have no idea if I'm even on the right track.

Thanks,
Insp Gadget
 
You need to have quotes around address in Range object
reference, as in "$G$38"
 

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