View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Function to read text file; find string; delete same before import

This is very simple. I don't know what you are refering to when you mean
FIND STRING since everything is a string in the TEXT file. It is also
important to know wher each line ends. Not sure if your code exactly
represents the text file. Open the file with Notepad and make sure WORD WRAP
(Format menu) is NOT checked. Then lok at text file and let me know where
the end of each line is located.

I have two methods of doing this task. I can import the file and then make
the changes in excel to delete the data you don't want. Or make the changes
before I put the data into spreadsheet.

If you want to try a quick experiment try to impor the dat manually.

From worksheet menue
1) Data - Import External Data - Import Data
2) Press Delimited - Next
3) Uncheck everything except Other and put the | in the box next to Other
4) Press finish and select where you want the data to go.

You can also turn on Record Macro before you do these operations to get a
macro.

" wrote:

2003

Need a VBA function to read text file; find string; delete same before import.

The function should find all instances (there can be many) of:
SELECT TO_CHAR(NET
AMT|DOC_NUM|FIPC|

the last line of the file

REPORT COMPLETE

In short, just the data please

SELECT TO_CHAR(NET
AMT|DOC_NUM|FIPC|
407.44|N6887008TORHMS5|D|22|AA|08|
2500.00|N6887008MDNC018|D|36|AA|08|
-2500.00|N6887008MDNC013|D|36|AA|08|
2133.18|N6887008MDNC013|D|36|AA|08
-1004.93|N6887008WR82003|D|36|AA|08|
SELECT TO_CHAR(NET
AMT|DOC_NUM|FIPC|
407.44|N6887008TORHMS5|D|22|AA|08|
2500.00|N6887008MDNC018|D|36|AA|08|
-2500.00|N6887008MDNC013|D|36|AA|08|
2133.18|N6887008MDNC013|D|36|AA|08
-1004.93|N6887008WR82003|D|36|AA|08|
REPORT COMPLETE

TIA any and all help greatly appreciated