![]() |
Best way to import fixed-width delimited text files into an array?
Should I use the Workbooks.OpenText Filename, or is there a faster way to
bring in the file? Actually, I may not even need the file in a worksheet, I just need the data in an array so I can use it to manipulate an existing excel file...so would it be faster to do some alternate type of file read directly into a 2-dimensional array? Thanks for any advise, Keith -- The enclosed questions or comments are entirely mine and don't represent the thoughts, views, or policy of my employer. Any errors or omissions are my own. |
Best way to import fixed-width delimited text files into an array?
You can use low level fileio:
http://www.applecore99.com/gen/gen029.asp http://support.microsoft.com/support...eio/fileio.asp File Access with Visual Basic® for Applications Sub ReadStraightTextFile() Dim LineofText As String Dim rw as Long rw = 0 Open "C:\FILEIO\TEXTFILE.TXT" For Input As #1 Do While Not EOF(1) Line Input #1, LineofText rw = rw + 1 ' now parse LineofText according to the column widths and ' put the values in an array. Loop 'Close the file Close #1 End Sub -- Regards, Tom Ogilvy "KR" wrote in message ... Should I use the Workbooks.OpenText Filename, or is there a faster way to bring in the file? Actually, I may not even need the file in a worksheet, I just need the data in an array so I can use it to manipulate an existing excel file...so would it be faster to do some alternate type of file read directly into a 2-dimensional array? Thanks for any advise, Keith -- The enclosed questions or comments are entirely mine and don't represent the thoughts, views, or policy of my employer. Any errors or omissions are my own. |
All times are GMT +1. The time now is 12:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com