View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Coza Coza is offline
external usenet poster
 
Posts: 38
Default My on-going problems with dates

I keep getting an error.
Not sure how or what to set to a String and a Double??

"NickHK" wrote in message
...
Look into using the DateAdd function to get the expiry date.

NickHK

"Coza" wrote in message
...
I seem to always be having problems with Dates for some reason.

The below code.
The followong finds the Value in Column A(rngfound)
Then in rngfound.offset(0,3) i have a DATE (say" 23 March 2007)
Then is rngfound.offset(0,5) i have a numerical value (Representing an
Amount of Years)

I want the code below to (At HIGHLIGHTED LINE) to ADD the Number of
years(rngfound.offset(0,5)) to the DATE (rngfound.offset(0,3),
to THUS give me an EXIRY Date.
IF this DATE is LESS that(<=) to TODAY's Date then the MSGBOX Appears.
If the Date is Greater then to Skip the MSGBOX.


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim rngFound As Range
On Error Resume Next
With Worksheets("Data").Range("A:A")
Set rngFound = .Find(What:=Me.ComboBox1.Value, After:=.Cells(1),
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False,
Matchbyte:=False)

If Now <= rngFound.Offset(0, 3).Value + rngFound.Offset(0, 5) * "365.25"
Then ' <=== HERE
' If Expired then WARNING Message
MsgBox "The [ " & rngFound.Offset(0, 5) & " ] Warranty Period has
Expired." & vbCrLf & vbCrLf & _
"Any Services carried out Should be Charged to [ " & rngFound.Offset(0,

2)
& " ].", vbInformation

Application.ScreenUpdating = True
Exit Sub
Else
'If Expiry Date is Not yet, then Carry on
End If
End With
UserForm3.Show
Unload Me
Application.ScreenUpdating = True
End Sub

What am i doing wrong, as i get the MSGBOX even though i set the Date to
Tomorrow's date to expire ?


Corey....