If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Macro to capture data from txt file - HELP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-30-11, 10:54
JeepMan JeepMan is offline
Registered User
 
Join Date: Oct 2011
Posts: 4
Macro to capture data from txt file - HELP

Hi,

I need help. I have a txt file that I would like to open via a macro. Once open I need to search for data from one line and move to excel then find additional data on the next line (s) in the txt file and move to the same output row in excel.

This is an EDI error file.

I need to capture the data that has TRN*2*value~
Just need to move the 10 first 10 bytes of the value to one cell then the next 9 bytes to the next cell in the same row.
The I need to capture the STC segment from the next row in the txt file to the next columns of the same row.
For example: Output should have:
1111111111 I12345678 A2 20
Actually the STC data has three parts usually before the *
Even better I would like to just write out only the TRN numbers and STC data for just the STCs that have A3 or A7.



See txt file:

ISA*00* *00* *ZZ*EMEDNYBAT *ZZ*491 *111029*2040*^*00501*111117220*0*P*;~
GS*HN*EMEDNYBAT*4XX*20111029*104022*15127220*X*005 010X214~
ST*277*041027220*005010X214~
BHT*0085*08*5057510*20111029*104022*TH~
HL*1**20*1~
NM1*PR*2*NYSDOH*****FI*111111111~
TRN*1*100027220~
DTP*050*D8*20111029~
DTP*009*D8*20111029~
HL*2*1*21*1~
NM1*41*2*THIS HOSPITAL*****46*491~
TRN*2*5057510~
STC*A1;20*20111029*WQ*45479.05~
QTY*90*2~
AMT*YU*45479.05~
HL*3*2*19*1~
NM1*85*2*THIS HOSPITAL*****XX*1111111111~
TRN*1*1130200000001293VF~
HL*4*3*PT~
NM1*QC*1*SMITH*JANE****MI*ZP75117M~
TRN*2*1110029032I60238045~
STC*A2;20*20111029*WQ*25693.4~
REF*1K*1130200041027220~
REF*BLT*111~
DTP*472*RD8*20111014-20111019~
HL*5*3*PT~
NM1*QC*1*JOHNSON*JOE****MI*WB64271Z~
TRN*2*1110029255I60238731~
STC*A3;400*20111029*WQ*19785.65~
REF*1K*1130200041027320~
REF*BLT*111~
DTP*472*RD8*20111016-20111019~
SE*31*111117220~
GE*10*11117220~
IEA*1*111117220~
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On