Hi,
-In what data type do you store the value returned by the in-box?
-What data type is the column you search (dates as strings or dates as dates)?
-How do you search and compare in the code (checking for any type implicit conversion)
Now, could you try comparing the values converted to a Long data-type. Say inbox is store in variable inbox and cell.value in cellVal:
Dim cellLong as long, inboxLong as long
cellLong = clng(cell)
inboxLong = clng(cdate(inbox))
'compare cellLong to inboxLong from now on.
Regards,
Sebastien
Main Topics
Browse All Topics





by: byundtPosted on 2005-02-07 at 15:06:29ID: 13249835
Hi jc31415,
When you use an input box to get a date, assign it to a variable formatted as date. You may then enter the date like any of the following and still have it converted into the correct date/time serial number:
October 21, 2005
10/21/05
10-21-2005
Sub DateInput()
Dim dat As Date
dat = InputBox("Enter a date")
MsgBox dat
End Sub
If the values in column C are text strings that look like dates, then you can convert them as follows:
1) Select and copy a blank cell
2) Select the cells with strings that look like dates
3) Edit...Paste Special...Add
4) Format the cells to the desired date format
If you are comparing in VBA, multiplying by 1, adding 0 or double negation will all coerce a conversion from string to date. Here is an example showing double negation
If --Cells(i,3)=dat Then 'Do your thing
Cheers!
Brad