View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mudraker[_384_] mudraker[_384_] is offline
external usenet poster
 
Posts: 1
Default 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