LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to read from txt file from bottom to top?

Hi,

I'm using excel 2007 and 2003. I have a routine to loop trough *.txt
files in a folder and search for string in a single line. All was fine
until I had to, based on found value, take all lines from this value
to top, e.g. When I find a line marked with specyfic marker ("in this
case "NC") I have to take all values from over this value until I
reach empty line (so looping backwards), then I continue searching.
Code samples (below function to copy data to specyfic cells)

Function move_all(LineofText, k)
Cells(k, "a") = Mid(LineofText, 2, 2)'Here if
Mid(LineofText, 2, 2) = "NC"
'macro should go back and pull all data until it reaches
empty line.
Cells(k, "b") = Mid(LineofText, 6, 8)
Cells(k, "c") = CLng(Mid(LineofText, 17, 10))
Cells(k, "d") = Str(Mid(LineofText, 29, 15))
Cells(k, "e") = CStr(Mid(LineofText, 46, 38))
Cells(k, "f") = CStr(Mid(LineofText, 86, 4))
Cells(k, "g") = Mid(LineofText, 91, 18)
Cells(k, "h") = Trim(Mid(LineofText, 100, 20))
Cells(k, "i") = Mid(LineofText, 125, 8)
Cells(k, "a").Activate
End Function

Thanks in advance for help

Regards
Piotr
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to read dates accross bottom of chart Bill43 Charts and Charting in Excel 4 September 13th 07 10:44 AM
I have a read only xl file, I need it to be read and write drama queen Excel Discussion (Misc queries) 3 July 1st 06 12:25 AM
XCEL FILE REC'D AS READ ONLY -- HOW TO NOT BE "READ ONLY" billybob Excel Discussion (Misc queries) 1 February 13th 06 03:14 AM
How can a file be converted from Read-Only to Read/Write Jim in Apopka Excel Discussion (Misc queries) 2 November 19th 05 04:59 PM
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. Tim Marsden Charts and Charting in Excel 2 October 15th 05 02:10 PM


All times are GMT +1. The time now is 03:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"