Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Question about a custom defined function

i have the following function which supposed to take a date and check it
against a lookup sheet that i have with flags whether the date five days
after the initial is weekend or bank holiday. if it is then it rolls a day
and does the checks again.

my problem is that the function goes to the first do and then when it
reaches the second do it exits

anyone can help me with this...


Public Function returndate(inidate As Date) As Date

Dim DatetoReturn As Date
Dim BHol, WkEnd As Boolean
Dim fstresult As String
Dim sstresult As Integer

BHol = True
WkEnd = True

DatetoReturn = inidate + 5

Do

Do While BHol = True
fstresult = Application.VLookup(DatetoReturn, Sheets("Dates
Lookup").Range("A:D"), 4)
If fstresult = "yes" Then
DatetoReturn = DatetoReturn + 1
Else
BHol = False
End If
Loop

Do While WkEnd = True
ssetresult = Application.VLookup(DatetoReturn, Sheets("Dates
Lookup").Range("A:D"), 2)
If sstresult = 6 Then
DatetoReturn = DatetoReturn + 2
ElseIf sstresult = 7 Then
DatetoReturn = DatetoReturn + 1
Else
WkEnd = False
End If
BHol = True
Loop

Loop Until BHol = False And WkEnd = False

returndate = DatetoReturn

End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Question about a custom defined function

i have identified that it exits when i try to do the vlookup function within
the loop.

"Panagiotis Marantos" wrote:

i have the following function which supposed to take a date and check it
against a lookup sheet that i have with flags whether the date five days
after the initial is weekend or bank holiday. if it is then it rolls a day
and does the checks again.

my problem is that the function goes to the first do and then when it
reaches the second do it exits

anyone can help me with this...


Public Function returndate(inidate As Date) As Date

Dim DatetoReturn As Date
Dim BHol, WkEnd As Boolean
Dim fstresult As String
Dim sstresult As Integer

BHol = True
WkEnd = True

DatetoReturn = inidate + 5

Do

Do While BHol = True
fstresult = Application.VLookup(DatetoReturn, Sheets("Dates
Lookup").Range("A:D"), 4)
If fstresult = "yes" Then
DatetoReturn = DatetoReturn + 1
Else
BHol = False
End If
Loop

Do While WkEnd = True
ssetresult = Application.VLookup(DatetoReturn, Sheets("Dates
Lookup").Range("A:D"), 2)
If sstresult = 6 Then
DatetoReturn = DatetoReturn + 2
ElseIf sstresult = 7 Then
DatetoReturn = DatetoReturn + 1
Else
WkEnd = False
End If
BHol = True
Loop

Loop Until BHol = False And WkEnd = False

returndate = DatetoReturn

End Function

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
Custom Format for User Defined Function [email protected] Excel Discussion (Misc queries) 5 August 7th 06 11:27 PM
Custom lists - not following defined order Darren Excel Worksheet Functions 1 February 21st 05 02:27 PM
#NAME? when using custom defined function Jules[_7_] Excel Programming 5 December 18th 04 01:04 AM
Question on Custom Sum Function Ray Batig Excel Programming 2 July 14th 04 11:44 PM
Custom defined formula billQ Excel Programming 2 July 15th 03 08:44 AM


All times are GMT +1. The time now is 07:21 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"