Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I'm hoping you can help. I'm trying to search the next line of a text file for a word called PAYDETAILS. If the word isn't there then in the worksheet i need to place "N/A". I have placed a shortened version of the program. I appreciate any help. Regards Frederic sub readtext() Dim strTextLine As String Dim strFilename As String Dim vFileHandle As Integer strFilename = "C:\Russell PSGCD.XFR.GRPN.D130809.F.S00570.txt" If Dir(strFilename) = "" Then MsgBox ("File Not Found") Exit Sub End If vFileHandle = FreeFile Open strFilename For Input As vFileHandle Do While Not EOF(vFileHandle) Line Input #vFileHandle, strTextLine If InStr(1, Left(strTextLine, 10), "CEG_HEADER") 0 Then Sheets("ECI File Index").Select NextRow = Range("O65536").End(xlUp).Row + 1 Range("O" & NextRow).Select ActiveCell = Mid(strTextLine, 40, 77) ElseIf InStr(1, Left(strTextLine, 10), "PAYDETAILS") 0 Then Sheets("ECI File Index").Select NextRow = Range("L65536").End(xlUp).Row + 1 Range("L" & NextRow).Select ActiveCell = Mid(strTextLine, 11, 5) NextRow = Range("M65536").End(xlUp).Row + 1 Range("M" & NextRow).Select ActiveCell = Mid(strTextLine, 16, 8) NextRow = Range("N65536").End(xlUp).Row + 1 Range("N" & NextRow).Select ActiveCell = Mid(strTextLine, 24, 12) end if loop Close vFileHandle end sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to read file in reverse fast line by line | Excel Programming | |||
Read value from text file line, process, then Loop until EOF | Excel Programming | |||
How can i read Command Line parametres from Excel 2003 file??? | Excel Programming | |||
Textbox-read text line by line | Excel Programming | |||
read last line of a file | Excel Programming |