In "Another List of Names.csv"
Male Names: Dave, Jack, John Female Names: Cindy, Mary, Pam
What I want is the following:
In Text Number One.csv:
Male Names: Dave, Jack, John
And in Text Number Two.csv
Female Names: Cindy, Mary, Pam
So far, I have the following code snippet:
Code: Select all
Sub AllEntriesToDifferentFiles()
Dim Xp, NEntry As Long
Dim strZ, strM, strF, strCropM, strCropF, strTrimStr, strEntrireLine As String
Open "C:\Users\John\Documents\Another List of Names.csv" For Input As #1
Open "C:\Users\John\Documents\Text Number One.csv" For Output As #3
Open "C:\Users\John\Documents\Text Number Two.csv" For Output As #4
strM = Trim("Male Names")
strF = Trim("Female Names")
strCropM = Left(strM, 25)
strCropF = Left(strF, 25)
While Not EOF(1)
Line Input #1, strZ
If InStr(1, strZ, strM, vbBinaryCompare) Then
Write #3, strM
End If
If InStr(1, strZ, strF, vbBinaryCompare) Then
Write #4, strF
End If
Wend
Close #4, 3, 1
End Sub
So far, it has given the output:
In Text Number One.csv:
Male Names
And in Text Number Two.csv:
Female Names
How could I improve this source code snippet, so that it can produce the output that I want?
Regards,
JohnDBCTX