How to extract specific words from text files into xls spreadsheet
<p>I'm new in VBA. Before posting my question here,I have spent almost 3 days surfing Internet.</p>

<p>I have 300+ text files (text converted from PDF using OCR),from text file. I need to get all words that contain "alphabet" and  "digits" (as example KT315A, KT-315-a, etc) along with source reference (txt file name).</p>

<p>What I need is </p>

<p>1.add "smart filter" that will copy only words that contains<br>
    "alphabets" and  "digits"</p>

<ol start="2">
<li><p>paste copied data to column A</p></li>
<li><p>add reference file name to column    B</p></li>
</ol>

<p>I have found code below that can copy all data from  text files into excel spreadsheet.</p>

<p>text files look like </p>

<p>"line from 252A-552A to ddddd, ,,, @,@,rrrr, 22 , ....kt3443  , fff,,,etc"</p>

<p>final result in xls should be</p>

<p>A | B  </p>

<p>252A-552A | file1 </p>

<p>kt3443 | file1</p>

<pre><code> Option Explicit


Const sPath = "C:\outp\" 'remember end backslash
Const delim = "," 'comma delimited text file - EDIT
'Const delim = vbTab  'for TAB delimited text files


Sub ImportMultipleTextFiles()
   Dim wb As Workbook
   Dim sFile As String
   Dim inputRow As Long

   RefreshSheet

   On Error Resume Next
   sFile = Dir(sPath &amp; "*.txt")

   Do Until sFile = ""
      inputRow = Sheets("Temp").Range("A" &amp; Rows.Count).End(xlUp).Row + 1

      'open the text file
'format=6 denotes a text file
      Set wb = Workbooks.Open(Filename:=sPath &amp; sFile, _
         Format:=6, _
         Delimiter:=delim)

      'copy and paste
      wb.Sheets(1).Range("A1").CurrentRegion.Copy _
         Destination:=ThisWorkbook.Sheets("Temp").Range("A" &amp; inputRow)
      wb.Close SaveChanges:=False

      'get next text file
      sFile = Dir()
   Loop

   Set wb = Nothing
End Sub


Sub RefreshSheet()
   'delete old sheet and add a new one
   On Error Resume Next

   Application.DisplayAlerts = False
      Sheets("Temp").Delete
   Application.DisplayAlerts = True

   Worksheets.Add
   ActiveSheet.Name = "Temp"

   On Error GoTo 0
End Sub
</code></pre>

<p>thanks!</p>