![]() |
Get Line From Text File
Hi I need to Select a line from a text file can someone please tell the best
way of doing this . TIA Charles |
Get Line From Text File
depends on how big the text file is, how to identify which line you require, is the line broken up into fields (columns), what is used to identify each column eg comar -- mudraker ------------------------------------------------------------------------ mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread...hreadid=540225 |
Get Line From Text File
I've just been doing something like this, where the location of what i wanted to copy out would change So, i used a file search in the file to find an "anchor" - a word or phrase that is fixed and doesn't change, then used that to move to the necessary data. For example, needed to find out how much was spent at midnight: TIMEBAND REPORT 0000 321 0001 564 0002 654 etc Searched for "TIMEBAND REPORT" then moved down a line. -- drucey ------------------------------------------------------------------------ drucey's Profile: http://www.excelforum.com/member.php...o&userid=32553 View this thread: http://www.excelforum.com/showthread...hreadid=540225 |
Get Line From Text File
The text file will one that I create with lines of information that I would
like to read by line, I need the best syntax of retrieving any line ramdomly from the file. TIA Charles "mudraker" wrote: depends on how big the text file is, how to identify which line you require, is the line broken up into fields (columns), what is used to identify each column eg comar -- mudraker ------------------------------------------------------------------------ mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread...hreadid=540225 |
Get Line From Text File
Try this for starters I am assuming you do not have more than 65536 rows in the text file Sub Macro1() Const conFile As String = "D:\MSN Hotmail - Message.txt" Const conFind As String = "TIMEBAND REPORT" Dim lRow As Long Workbooks.OpenText Filename:=conFile, Origin:= _ xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False Semicolon:=False _ , Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _ TrailingMinusNumbers:=True lRow = Cells.Find(What:=conFind, After:=ActiveCell, LookIn:=xlFormula _ , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Row MsgBox Cells(lRow + 1, 1).Value End Su -- mudrake ----------------------------------------------------------------------- mudraker's Profile: http://www.excelforum.com/member.php...nfo&userid=247 View this thread: http://www.excelforum.com/showthread.php?threadid=54022 |
All times are GMT +1. The time now is 02:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com