Sub ImportData(iFile As String)
Dim dic As Object, ar
Dim y As Long, x As Long
Dim intFF As Integer: intFF = FreeFile()
Open iFile For Input As #intFF
y = 1
Set dic = CreateObject("Scripting.Dictionary")
Do Until EOF(1)
Line Input #intFF, ReadData
With CreateObject("VBScript.RegExp")
.Global = True
.Pattern = "(\[INT.+?: \d{4}-\d{2}-\d{2}_.+?data\.ms.*])$|(Header=,.+)|(\d.?\=\,\s.?\d.+$)"
If .Test(ReadData) Then
dic(ReadData) = 1
End If
End With
Loop
Close #intFF
sRow = IIf(Cells(Rows.Count, "A").End(xlUp).Row = 1, 1, Cells(Rows.Count, "A").End(xlUp).Row + 1)
x = Application.RoundUp(dic.Count / 2, 0)
For Each Key In dic.Keys
If y <= x Then
Range("A" & sRow + y - 1) = Key
Else
With CreateObject("VBScript.RegExp")
.Pattern = Chr(34) & "[^\\" & Chr(34) & "]*(\\.[^\\" & Chr(34) & "]*)*" & Chr(34) & "|[^, ]+"
.Global = True
If .Execute(Key).Count < 10 Then
Range("L" & sRow + y - x) = Key
Else
y = y - 1
End If
End With
End If
y = y + 1
Next
Set dic = Nothing
End Sub
Sub CheckAllSubFold()
Dim path As String: path = ThisWorkbook.path & "\"
Dim fName As String: fName = "*.CSV"
Dim cPath As String, coll As New Collection
cPath = Dir(path, vbDirectory)
Do While Len(cPath) > 0
If Left(cPath, 1) <> "." And _
(GetAttr(path & cPath) And vbDirectory) = vbDirectory Then
coll.Add path & cPath & "\"
End If
cPath = Dir()
Loop
For I = 1 To coll.Count
fName = Dir(coll.Item(I) & "*.csv")
ImportData coll.Item(I) & fName
fName = Dir()
Next
Range("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Comma:=True
Range("L:L").TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Comma:=True
Range("L:L").Delete
End Sub