Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I wish to import financial data from numerous text files into Excel
worksheets. The text files are fixed width, designed for printing one page each. But the column formatting varies from file to file, and sometimes varies within file (the top half will have 5 columns, the bottom half two). I *think* the following is the general approach I need to use (and my questions are contained in brackets): 1. Open text file and read start a loop to read in one line at a time.[I think I know how to code this; pretty sure I want sequential input.] 2. Search for key words (e.g. Assets, Securities) that signify the desired line [how do I say 'if line contains "Assets" then...'? The keyword may not always be at the start of the line.] 3. When desired line is found, then use MID function to extract the desired substring [I should be able to use specific position counts as long as the file format doesn't change.] Convert that sub-string to a number [syntax?? for this step] [Will leading blanks in the sub-string cause a conversion error? How would a string of blanks be converted, if at all?] 4. Place number in array and end loop. [How, if I need to, do I begin again at line one of a particular file for a new keyword search?] 5. When all data is collected, write array to an excel column. Final question: A total of about 240 files are involved. Is there a more efficient method out there, or will this be fast enough (I'm prepared to wait 5 minutes, not 30, for this to chug along). As you can tell from the questions, I'm a newbie. Any and all help appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
assign values to specific cells in an excel sheet through text file | Excel Discussion (Misc queries) | |||
Inserting text from external file into cells. | Excel Discussion (Misc queries) | |||
Excel VBA - open text file, replace text, save file? | Excel Programming | |||
excel vba : how to split characters in text file into cells? | Excel Programming | |||
Cells to Columns in Text File | Excel Programming |