Supposing:
- the 160 files are xls files in directory "C:\wordcount"
- the word you are looking for doesn't appeat twice in a cell.
Sub snb()
On error resume next
c05="Word to look for"
c00 = "C:\wordcount\"
c01 = Dir(c00 & "*.xls")
Do Until c01 = ""
With Workbooks.Add(c00 & c01)
x = 0
For Each Sh In .Sheets
Sh.Cells.Replace c05, "=110/0"
x = x + Sh.Cells.SpecialCells(xlCellTypeFormulas, xlErrors).Count
Next
.Close False
End With
c02 = c02 & vbCr & "in " & c01 & ": wordfrequency = " & x
c01 = Dir
Loop
ThisWorkbook.Sheets(1).Cells(1, 1).Resize(UBound(Split(c02, vbCr))) = Application.Transpose(Split(Mid(c02, 2), vbCr))
End Sub
Bookmarks