Is there VBA code that would search a folder full of files, only grab information in certain rows that match values specified, and put those values in a new spreadsheet in a new row for each file with the matching information.
Any help would be great! Thank you!
Probably the simplest thing would be to use
Dir$() to loop through the files,
Open them for
Input, and read them line by line and examine the strings. There are other (and probably better) ways, of course. For instance, using the Scripting Runtime lets you make use of FileSystemObject with various capabilities for finding and accessing folders, files, etc.
Anyway, here's a very quick sample (not tested) of the simpler Dir$ method...
- Dim FileName As String, Text As String
-
FileName = Dir$("C:\Test\abc*.txt") ' Use your own wildcard here
-
While FileName <> ""
-
Open FileName For Input Access Read Shared As #1
-
Do Until EOF(1)
-
Line Input #1, Text
-
If <this string passes some test> Then
-
<Grab the information and put it wherever>
-
End If
-
Loop
-
FileName = Dir$
-
Loop