LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
millsy
 
Posts: n/a
Default UDF's using other UDF's


The change makes no difference other than to highlight the lack of a
declaration. I agree with your advice but I don't see how it was going
to make any difference anyway. Here's the revised code with all
variable declared. I also changed one of the if statements but that
isn't relevant to the error:

Option Explicit


Function TimeDiff(BeginTime As Integer, EndTime As Integer) As Single

Dim BeginHour As Integer, BeginMinute As Integer
Dim EndHour As Integer, EndMinute As Integer

If EndTime < BeginTime Then EndTime = EndTime + 2400

BeginHour = Int(BeginTime / 100)
BeginMinute = BeginTime - (BeginHour * 100)
BeginTime = (BeginHour * 60) + BeginMinute

EndHour = Int(EndTime / 100)
EndMinute = EndTime - (EndHour * 100)
EndTime = (EndHour * 60) + EndMinute

TimeDiff = (EndTime - BeginTime) / 60

End Function



Function FindCase(Ws As Integer, We As Integer, Rs As Integer, Re As
Integer) As Single
Dim WsRs As Single, RsWe As Single, WsWe As Single, WsRe As Single,
RsWs As Single, WeRe As Single, RsRe As Single, ReWe As Single

WsRs = TimeDiff(Ws, Rs)
RsWe = TimeDiff(Rs, We)
WsWe = TimeDiff(Ws, We)
WsRe = TimeDiff(Ws, Re)
RsWs = TimeDiff(Rs, Ws)
RsRe = TimeDiff(Rs, Re)
WeRe = TimeDiff(We, Re)

FindCase = 0

If WsRs + RsWe = WsWe Then FindCase = FindCase + 1
If RsWs + WsWe + WeRe = RsRe Then FindCase = FindCase + 10
If WsRe + ReWe = WsWe Then FindCase = FindCase + 100
If WsRs + RsRe + ReWe = WsWe Then FindCase = FindCase + 1000

End Function


--
millsy
------------------------------------------------------------------------
millsy's Profile: http://www.excelforum.com/member.php...fo&userid=5122
View this thread: http://www.excelforum.com/showthread...hreadid=494261



 
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



All times are GMT +1. The time now is 10:42 PM.

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"