Excel VBA import pieces of prn file via position

patbuk

New Member
Joined
Aug 22, 2012
Messages
9
Hello, I had created some macros years ago that would take a prn file and import it according to the table columns which I would manipulate further. However, I needed some of the preceding header information so I just let it break across columns and then concatenate later to get the full text string. Because the incoming data would change, that was not always the cleanest solution.

Now the source system has changed the widths of the incoming data and I have to redo these, I'm wondering if there is a way to import text by position in the prn: for example lines 6,7,8 positions 10 through 40 would go into 3 separate cells in the Excel spreadsheet. Lines 6,7,8 positions 51 thru 81 would go into 3 other cells. There would be other header info to import in the first 8 rows. Then rows 9 to LR would be the spreadsheet that needs to get cleaned up.

I'm interested in seeing if this can be done.
Following is the top portion of the prn before it goes into columns. Thank you.

PHP:
        PURCHASE ORDER NO. 7448                             VENDOR- SD01      PAGE 1 
05/15/17         TERMS-                             SHIP VIA-
SEND TO: STANDARD MOTOR PRODUCTS        BILL/     MYCOMPANY, INC.
         7070 GOLF COURSE RD.             SHIP TO:440 ASHLAND ST S.W.
         DISPUTANA VA. 23842                      CICERO, MI  49507
LINE                                      ORDR       PKG                              WD     CORE
 NO. PART NUMBER                           QTY  UM   QTY  DESCRIPTION     WEIGHT    INVOICE  PRICE CODE
 --- -----------                           ---  --   ---  -----------     ------    -------  ----- ----
   1 AS523                                   1  EA     1  SENSOR             0.4     43.41    0.00  Q  
   2 CBS2140                                 1  EA     1  CMBN SWITCH        0.3    122.49    0.00  Q  
   3 CP443                                   1  EA     1  STANDARD FUEL VA   3.0     73.56    0.00  Q  
   4 CVS91                                   1  EA     1  VAPOR CANISTER V   0.3     38.11    0.00  Q  
   5 DV142                                   1  EA     1  DIVERTER VALVE     1.5    142.12    0.00  Q  
   6 ETB54                                   1  EA     1  EGR TUBE           0.5     25.97    0.00  Q
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top