Telecommm
Try this:
Sub ReadBSS()
Dim sFname As String
Dim lFnum As Long
Dim lRowCnt As Long
Dim sLine As String
Dim lBssFound As Long
sFname = "C:\tester.txt"
lFnum = FreeFile
Open sFname For Input As lFnum
Do While Not EOF(lFnum)
Line Input #lFnum, sLine
If sLine = "BSS" Then
lBssFound = 1
End If
If lBssFound 1 Then
lRowCnt = lRowCnt + 1
Sheet1.Cells(lRowCnt, 1).Value = sLine
End If
If lBssFound = 21 Then
lBssFound = 0
End If
If lBssFound = 1 Then
lBssFound = lBssFound + 1
End If
Loop
End Sub
--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com
Telecommm wrote:
Hi Experts,
Hoping you in good health. I have the following question:
I have a text file which is approximately 50 to 70 pages long. It
contains a specific word "BSS" again and again, what I want to do is
to design an excel sheet which takes this text file as input and
finds out this required word (which is BSS), copy the next 20 words
after BSS and paste it into excel sheet in cell B4. It should search
the text file again and find the word BSS, and copies next 20 words
in cell B5 and so on.
Thanks for your support