Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Solution required

Hi All,

I have a full movement report of a vehicle and I have to check the status of
movement, following are the statuses

If vehicle Movmed from 05:30 to 13:30 then Its "1st Trip"
if vehicle moved from 13:30 to 21:30 then its "2nd Trip"
if vehicle moved from 21:30 to 05:30 then its "Private"
if vehicle moved before 05:30 to after 05:30 then its "Private / 1st"
if vehicle start before 13:30 and off after 13:30 then its "1st / 2nd"
if vehicle start before 21:30 and off after 21:30 then its "2nd / Private"

Thanks in advance

Hassan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Solution required

Option Explicit
Sub test()
MsgBox GetPeriods("05:30", "13:30")
MsgBox GetPeriods("13:30", "21:30")
End Sub

Function GetPeriods(startTime As String, stopTime As String) As String
Dim text1 As String
Dim text2 As String
text1 = GetPeriod(startTime)
text2 = GetPeriod(stopTime)
If text1 = text2 Then
GetPeriods = text1
Else
GetPeriods = text1 & " / " & text2
End If
End Function
Function GetPeriod(stime As String) As String
Select Case CDate(stime)
Case Is < CDate("05:30")
GetPeriod = "Private"
Case Is <= CDate("13:30")
GetPeriod = "1st Trip"
Case Is <= CDate("21:30")
GetPeriod = "2nd Trip"
Case Else
GetPeriod = "Private"
End Select
End Function

"Hassan" wrote in message
...
Hi All,

I have a full movement report of a vehicle and I have to check the status
of
movement, following are the statuses

If vehicle Movmed from 05:30 to 13:30 then Its "1st Trip"
if vehicle moved from 13:30 to 21:30 then its "2nd Trip"
if vehicle moved from 21:30 to 05:30 then its "Private"
if vehicle moved before 05:30 to after 05:30 then its "Private / 1st"
if vehicle start before 13:30 and off after 13:30 then its "1st / 2nd"
if vehicle start before 21:30 and off after 21:30 then its "2nd / Private"

Thanks in advance

Hassan

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
solution wants shoyeb2045 Excel Discussion (Misc queries) 4 August 14th 08 08:34 PM
VBA solution required? Michael Excel Programming 2 January 24th 08 05:37 PM
odd vlookup solution required - can you rise to the challenge?! Danny Bhoy Excel Programming 2 January 16th 08 09:21 AM
Is There A Solution.......? Thyagaraj Excel Programming 3 August 8th 06 03:59 PM
Solution Required to prevent #Ref! when rows deleted Andibevan Excel Worksheet Functions 3 September 6th 05 01:39 PM


All times are GMT +1. The time now is 09:14 AM.

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

About Us

"It's about Microsoft Excel"