Code:
Dim wb As Workbook
Dim ws As Worksheet
Dim objFSO, strTextFile, strData, arrLines, LineCount
Dim ReceivedTrans, Mis As Integer
Dim MyFolder, MyFile, MyFileName, MySheetName, ReportDate As String
Dim FileType As String
Dim i, j As Integer
Const ForReading = 1
i = 1
j = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
MyFolder = "D:\TotalCompare"
MyFile = Dir(MyFolder & "\*.txt")
Do While MyFile <> ""
If Left(MyFile, 21) = "ReverseFile_FOOD4514_" Or Right(MyFile, 12) = ".xls_RES.txt" Then
If Left(MyFile, 21) = "ReverseFile_FOOD4514_" Then
strTextFile = MyFile
strData = objFSO.OpenTextFile(strTextFile, ForReading).ReadAll
arrLines = Split(strData, vbCrLf)
LineCount = UBound(arrLines)
Set objFSO = Nothing
MySheetName = Replace(MyFile, "txt", "")
ReportDate = Right(Replace(MySheetName, ".", ""), 8)
MyFileName = Replace((Replace(MySheetName, "_" & ReportDate & ".", "")), "ReverseFile_FOOD4514_", "")
ReceivedTrans = LineCount
On Error Resume Next
strTextFile = MyFileName & ".txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
strData = objFSO.OpenTextFile(strTextFile, ForReading).ReadAll
arrLines = Split(strData, vbCrLf)
LineCount = UBound(arrLines)
Set objFSO = Nothing
Mis = LineCount
End If
End If
MyFile = Dir
Loop