The macro below extracts information from a text file and pastes the data to cell D7. How do I change this so that: (1) it extracts information from multiple text files residing in C:\MyReports folder (the filename + path is stored in column G, starting in row 7); (2) pastes the data to column D, starting in row 7.
Code:
Sub GetInfoFromTextFile()
Dim strLine As String
Dim strLineOut As String
Dim i As Long
With CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\MyReports\sample.txt")
strLine = .ReadAll
.Close
End With
With CreateObject("VBScript.RegExp")
.Global = False
.MultiLine = True
.Pattern = "(<date)(.+)(/>)"
If .Test(strLine) Then
strLine = .Execute(strLine)(0)
For i = 1 To Len(strLine)
If IsNumeric(Mid(strLine, i, 1)) Then
strLineOut = strLineOut & Mid(strLine, i, 1)
End If
Next
Range("D7").Value = CLng(strLineOut)
End If
End With
End Sub