View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mettext[_2_] Mettext[_2_] is offline
external usenet poster
 
Posts: 1
Default Returning Dates - Lead Times

Please help - I'm new to VBA
I have a Calender file, where I match a date. The file contains date
followed by a flag "Y" for weekends and Bank holidays and " " fo
weekdays.
String
1 - 10 = Date
11- 11 = WeekEnd or Bank Holiday
12- 13 = Week Number
14- 14 = Bank Holiday
08/04/2004 15
09/04/2004Y15Y
10/04/2004Y15
11/04/2004Y16
12/04/2004Y16Y
13/04/2004 16
14/04/2004 16
15/04/2004 16
16/04/2004 16
17/04/2004Y16
My problem is that when I find a date match I need to count 4 lead day
with the Flag set to " " (no weekend or bank holidays) and return th
new date. HELP!
Example
oldDate = 08/04/2004 (Day 0)
LeadDays = 4
newDate = 16/04/2004

Code:
Function AddLeadTime(oldDate, LeadDays)
Dim LineData As String, MyStr As String, x
Open "C:\Test Lib\DateFile.txt" For Input As #1 ' Open the file.
Do While Not EOF(1) ' Continue reading until end-of-file.
x = x + 1 ' Line Counter
Line Input #1, LineData ' Read a line of data.
' Store each date from line of data as variable.
MyStr = Mid(LineData, 9, 6) & Mid(LineData, 17, 2)
If oldDate = MyStr Then
Debug.Print oldData, LeadDays, x
End If
Loop
Close #1
End Function

Thanks in advance

--
Message posted from http://www.ExcelForum.com