If statment

J

jon

Hi all.

Having trouble with an if statement.

What I am trying to do is as follows

If dateIcyBaan = today's date and it is a Sunday

then ok end

Else if dateIcyBaan = today's date and before 7:30am then
dateIcyBaan = vbadate - 1

Else if dateIcyBaan = today's date and after 7:30am and weekday =
Saturday then
dateIcyBaan = vbadate + 1

The code I am using now is below but at the moment it dose the following
Alters nothing.

without the Sunday if statement the other 2 statements run as required.


If dateIcyBaan = VBA.date() And WeekDay(7) Then
dateIcyBaan = VBA.date

ElseIf dateIcyBaan = VBA.date() And time < #7:30:00 AM# Then
dateIcyBaan = VBA.date - 1

ElseIf dateIcyBaan = VBA.date() And time > #7:30:00 AM# And
WeekDay(7) Then
dateIcyBaan = VBA.date + 1

End If


Thanks

Jon
 
D

Douglas J. Steele

If dateIcyBaan = VBA.Date() Then
If WeekDay(dateIcyBaan) = vbSunday Then
dateIcyBaan = VBA.date
ElseIf Time < #7:30:00 AM# Then
dateIcyBaan = VBA.date - 1
Else
dateIcyBaan = VBA.date + 1
End If
Else
' Do you want anything done when dateIcyBaan isn't today?
End If
 
J

jon

Done

Thanks very much
Jon


Douglas J. Steele said:
If dateIcyBaan = VBA.Date() Then
If WeekDay(dateIcyBaan) = vbSunday Then
dateIcyBaan = VBA.date
ElseIf Time < #7:30:00 AM# Then
dateIcyBaan = VBA.date - 1
Else
dateIcyBaan = VBA.date + 1
End If
Else
' Do you want anything done when dateIcyBaan isn't today?
End If
 

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

Top