Hello,
I have this macro that copies some data from a particular range to a text file:
Sub txtreport()
Dim folderDest As String
Dim fileName As String
Dim FSO As Object
Dim oFile As Object
Dim Entry As Range
Dim newDtop As Long
Dim newDbot As Long
Dim NewTxtFile
fileName = "name" & "_" & "name.txt"
folderDest = "C:\Dest\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.CreateTextFile(folderDest & fileName)
newDtop = [H2].End(xlDown).Offset(2, 0).Row
newDbot = [G1048576].End(xlUp).Row
For Each Entry In Range(Cells(newDtop, 3), Cells(newDbot, 3))
oFile.Write Entry.Value & "" & vbCrLf & ""
Next Entry
NewTxtFile = Shell("C:\WINDOWS\notepad.exe C:\Dest\name_name", 1)
End Sub
But I only want it to copy the data from:
Range(Cells(newDtop, 3), Cells(newDbot, 3))
where text "Parot" is available in:
Range(Cells(newDtop, 7), Cells(newDbot, 7))
A simple filter doesn't work in this case...
Your input would be greatly appreciated
This how I thought of doing it:
For Each Entry In Range(Cells(newDtop, 3), Cells(newDbot, 3))
If Range(Cells(newDtop, 7), Cells(newDbot, 7)).Value = "Parot" Then
oFile.Write Entry.Value & "" & vbCrLf & ""
End If
Next Entry
Of course this doesn't work...
Bookmarks