![]() |
Validation issue
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 |
Validation issue
You need to have quotes around address in Range object
reference, as in "$G$38" -----Original Message----- 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 . |
Validation issue
Thanks for the easy fix. Much appreciated!
Insp Gadget |
All times are GMT +1. The time now is 10:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com