Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the If command for a date

Status
Not open for further replies.

Joep1972

Technical User
Nov 24, 2002
13
NL

Hello can somebody help me with the following,

I'm trying in a userform to get a difference in a date especially for the month, if in the calender the date is 1-11-02 then it has to right the information to the cell (H14 and i14) but if the date is in december then it has to write the info to 2 other cells and so on and so on.
see here what i've got up to now but this isn't working.

Private Sub CommandButton3_Click()
if Me.Calendar1.date < 1.12.02 Then
Worksheets(&quot;Test&quot;).Cells(14, 8).Value = Me.TextBox1.Text
Sheets(&quot;test&quot;).Cells(14, 9) = Me.Calendar1.Day
Sheets(&quot;Budget Maand November 2002&quot;).Select
End If
if Me.Calendar1.date < 1.12.02Then
Worksheets(&quot;Test&quot;).Cells(14, 8).Value = Me.TextBox1.Text
Sheets(&quot;test&quot;).Cells(14, 9) = Me.Calendar1.Day
Sheets(&quot;Budget Maand December 2002&quot;).Select
End If
Unload Me
End Sub


I hope you VBA Experts can help me once again.

Joep
 
I've not used the Calendar control you are using. Assuming the .date property of the control is an Excel-compatible serial date/time, you would use

if Calendar1.date < datevalue(&quot;1/2/02&quot;) then
...

Rob
[flowerface]
 

Seems to work like this......

If Calendar1.Value < DateValue(&quot;01/12/2002&quot;) then



mudstuffin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top