LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Require extra funtionality - existing code included

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
encountered and there is no "YP_TRX_CURR"
i.e
10123568.01,YP_TRX_PREV
10123568.01,YP_TRX_INCR


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?

Thanks
Hilton



 
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
Sumproduct - please add extra funtionality Hilton Excel Discussion (Misc queries) 1 May 27th 08 04:24 PM
Adding an extra row after every existing row Josh W Excel Discussion (Misc queries) 10 April 14th 08 09:56 PM
I require code to run a macro dependant on the date Marie Bayes Excel Discussion (Misc queries) 7 January 15th 07 03:48 PM
require macro or code for purchase order to do the following: jatman Excel Worksheet Functions 0 August 11th 06 06:02 AM
adding extra text into an existing column Zach Excel Worksheet Functions 2 August 11th 05 05:26 PM


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