Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How to allocate movement if expected last record is missing

Hi,

I'm not an accomplished programmer so please bear with me. Here is very
rudimentary code I have written. No doubt there are better ways of doing
this. However I ran this on a sample file and it does what I want it to
do.However I need some help to incorporate an aspect I cannot seem to get
right.


Input File Sample
Tline, 8, 11, Tline, 386, 16
10123567.01,YP_TRX_PREV
10123567.01,YP_TRX_CURR
10123568.01,YP_TRX_PREV
10123568.01,YP_TRX_INCR
10123569.01,YP_TRX_PREMINV
10123569.01,YP_TRX_CURR

Would like to see this
10123567.01 YP_TRX_PREV, PREV
10123567.01 YP_TRX_CURR, CURR
10123568.01 YP_TRX_PREV, PREV
10123568.01 YP_TRX_INCR, OFF
10123569.01 YP_TRX_PREMINV, PREMINV
10123569.01 YP_TRX_CURR, CURR


Dim Tline As String
Dim SegStr As String
Dim i As Long
Dim TrxStr, PolStr as string


Line Input #1, Tline
InitPolRef = Mid$(Tline, 8, 11)
'eg 100123567.01
TrxStr = Mid$(Tline, 386, 16)

'First Record
If TrxStr < "YP_TRX_PREV " Then
TrxStr = "NBUS"
Else
TrxStr = Right(TrxStr, 9)
End If

SegStr = Mid$(Tline, 1, 2) & Mid$(Tline, 3, 2) & Mid$(Tline, 5, 2) &
Mid$(Tline, 7, 12) & Mid$(Tline, 24, 9)
& Mid$(Tline, 35, 2) & Mid$(Tline, 37, 2) & Mid$(Tline, 39, 2) & Mid$(Tline,
41, 2)
Print #2, SegStr & "," & TrxStr


'Balance of Records
i = 2
Do Until EOF(1)
Line Input #1, Tline
PolStr = Mid$(Tline, 8, 11)
TrxStr = Mid$(Tline, 386, 16)


'If 2nd record(Polstr) = 1st record(InitPolRef)
If InitPolRef = PolStr Then
TrxStr = Right(TrxStr, 9)

'If 2nd record(Polstr) < 1st record(InitPolRef)
Else
PolStr = Mid$(Tline, 8, 11)
InitPolRef = PolStr

If TrxStr < "YP_TRX_PREV " Then
TrxStr = "NBUS"
Else
TrxStr = "PREV"
End If

End If

SegStr = Mid$(Tline, 1, 2) & Mid$(Tline, 3, 2) & Mid$(Tline, 5, 2) &
Mid$(Tline, 7, 12) & Mid$(Tline, 24, 9)
& Mid$(Tline, 35, 2) & Mid$(Tline,37, 2) & Mid$(Tline, 39, 2) & Mid$(Tline,
41, 2)
Print #2, SegStr & "," & TrxStr

i = i + 1
Loop

Close #1
Close #2

MsgBox ("End of Run: ") + Str(i - 1) + " records processed"



I need to put in an "OFF" movement when the LAST record of a series is NOT
"YP_TRX_CURR" i.e
10123568.01,YP_TRX_PREV
10123568.01,YP_TRX_INCR

Result
10123568.01 YP_TRX_PREV, PREV
10123568.01 YP_TRX_INCR, OFF

If it helps the file is sorted by "Tline, 8, 11" field and there is a date
associated with each "Tline, 386, 16" field.

Hope I have not irritated people by this long-winded explanation. Can anyone
help please, please, please...?

Thanks
Hilton


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
find a record with a missing value Edward Excel Discussion (Misc queries) 1 April 8th 10 06:04 AM
Simple calc not working as expected - what am I missing? MarianneS40 Excel Discussion (Misc queries) 7 October 12th 09 05:03 PM
How many days the ready stock+expected stock will last as allocate Narnimar Excel Discussion (Misc queries) 0 September 16th 08 05:57 PM
Identify missing record numbers Earl Excel Worksheet Functions 3 November 16th 05 02:59 PM
Identify missing record numbers kabobot Excel Discussion (Misc queries) 4 January 5th 05 05:30 PM


All times are GMT +1. The time now is 06:08 PM.

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"