Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default VBA - A Problem with Dates.

Greetings intrepid VBA users!

I have a problem, a problem with dates.

I have a Constant criteria of 20

I also have a data range of different records that contain two dates,

DateFrom - the date the holiday starts
DateTo - The date the holiday ends

I'm trying to check when a user requests a new hoilday it will check all
these records, and see if this new holiday (which contains two dates, dateTo,
dateFrom) can be processed. It CAN'T be processed if 20 hoildays from records
are in affect when the user wants a holiday.

E.G

I have a bucket load of holidays, 20 of these already exist from 04/04/08 to
06/04/08.

Can't except anymore for them dates, BUT I can't also accept any dates that
partially cover these dates so if the user inputted DateTo = 05/04/08 to
08/04/08 that would also tell the user that he'd have to change dates.

Thank you in advance for any help given!

I hope I have explained myself clearly, if not, then I'll attemp to explain
again.
I think I may just need a clever IF statement in vba code, not sure though.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default VBA - A Problem with Dates.

On Apr 5, 2:18*am, NateBuckley
wrote:
Greetings intrepid VBA users!

I have a problem, a problem with dates.

I have a Constant criteria of 20

I also have a data range of different records that contain two dates,

DateFrom - the date the holiday starts
DateTo - The date the holiday ends

I'm trying to check when a user requests a new hoilday it will check all
these records, and see if this new holiday (which contains two dates, dateTo,
dateFrom) can be processed. It CAN'T be processed if 20 hoildays from records
are in affect when the user wants a holiday.

E.G

I have a bucket load of holidays, 20 of these already exist from 04/04/08 to
06/04/08.

Can't except anymore for them dates, BUT I can't also accept any dates that
partially cover these dates so if the user inputted DateTo = 05/04/08 to
08/04/08 that would also tell the user that he'd have to change dates.

Thank you in advance for any help given!

I hope I have explained myself clearly, if not, then I'll attemp to explain
again.
I think I may just need a clever IF statement in vba code, not sure though..


Hi Nate,

As far as I can see you'd have to loop through all the existing
records and for each one do the following:

Call Start1 and End1 the dates of the existing record.
Call Start2 and End2 the date of the proposed leave.
We also need a counter starting at 0 : i =0

Do Until i = 20
Set Start1 and End1 to new row / record whatever.
If Not(End1 < Start2 Or Start1 End2) Then i = i + 1
Loop

If i = 20 Then
MsgBox "No Holidays for you!"
Else
MsgBox "Good choice, enjoy your break!"
End If

I hope I got the order of the dates correct in the overlap
exclusion... it's very late over here :)

Cheers,
Ivan.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default VBA - A Problem with Dates.

Cheers Ivy, sorry about the amount of time it took to reply, but that will do
the trick.

Thanks again!

"Ivyleaf" wrote:

On Apr 5, 2:18 am, NateBuckley
wrote:
Greetings intrepid VBA users!

I have a problem, a problem with dates.

I have a Constant criteria of 20

I also have a data range of different records that contain two dates,

DateFrom - the date the holiday starts
DateTo - The date the holiday ends

I'm trying to check when a user requests a new hoilday it will check all
these records, and see if this new holiday (which contains two dates, dateTo,
dateFrom) can be processed. It CAN'T be processed if 20 hoildays from records
are in affect when the user wants a holiday.

E.G

I have a bucket load of holidays, 20 of these already exist from 04/04/08 to
06/04/08.

Can't except anymore for them dates, BUT I can't also accept any dates that
partially cover these dates so if the user inputted DateTo = 05/04/08 to
08/04/08 that would also tell the user that he'd have to change dates.

Thank you in advance for any help given!

I hope I have explained myself clearly, if not, then I'll attemp to explain
again.
I think I may just need a clever IF statement in vba code, not sure though..


Hi Nate,

As far as I can see you'd have to loop through all the existing
records and for each one do the following:

Call Start1 and End1 the dates of the existing record.
Call Start2 and End2 the date of the proposed leave.
We also need a counter starting at 0 : i =0

Do Until i = 20
Set Start1 and End1 to new row / record whatever.
If Not(End1 < Start2 Or Start1 End2) Then i = i + 1
Loop

If i = 20 Then
MsgBox "No Holidays for you!"
Else
MsgBox "Good choice, enjoy your break!"
End If

I hope I got the order of the dates correct in the overlap
exclusion... it's very late over here :)

Cheers,
Ivan.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with dates [email protected] Excel Programming 1 June 7th 07 01:36 AM
dates problem mita Excel Discussion (Misc queries) 4 June 2nd 06 12:19 PM
Dates Problem nicole0904 Excel Discussion (Misc queries) 5 May 10th 06 02:47 PM
VBA / SQL: problem with dates Santiago[_2_] Excel Programming 17 August 3rd 05 06:45 PM
problem with dates Alex G Excel Programming 2 January 2nd 04 03:20 PM


All times are GMT +1. The time now is 02:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"