Hi..
Although solved for you.. here's an alternative for you or others..
Note: Change fPath to suit..
Private Sub CommandButton1_Click()
Dim x, y, z, myval As String, fPath As String, fName As String
fPath = "C:\Users\apo\Desktop\": fName = "Test"
myval = """parot"""
With Range("H" & Range("H" & Rows.Count).End(xlUp).Row).CurrentRegion
x = .Value: y = .Columns(7).Value
z = Application.Transpose(Filter(Evaluate("Transpose(if(" & .Columns(7).Address & "=" & myval & ",row(1:" & .Rows.Count & "),char(32)))"), Chr(32), False))
If UBound(z) > -1 Then
With CreateObject("Scripting.FileSystemObject").CreateTextFile(fPath & fName & ".txt", True)
.writeline Join(Application.Transpose(Application.Index(x, z, [Transpose(row(3:3))])), vbCrLf)
End With
End If
End With
End Sub
Bookmarks