Rob342
04-19-2012, 05:17 AM
Hi Guys
Really need some help with this one, to match a record in a text file with a record on excel
I have already opened the text file & selected the correct record as per attachments, but really need to know how to match the claim no & post the values to the sheet "DBase".
This is where is starts & ends at the mo
If somebody can show me how to match the claim & get the 1st bit of data back in the sheet then i might able to carry on!
Sub ImportMatchData()
Dim FSO As Object '<-- FileSystemObject
Dim fsoTStream As Object '<-- TextStream
Dim fsoFile As Object '<-- File
Dim strLine As String
Set FSO = CreateObject("Scripting.FileSystemObject")
For Each fsoFile In FSO.GetFolder(ThisWorkbook.Path & "\").Files
If fsoFile.Type = "Text Document" Then
Set fsoTStream = FSO.OpenTextFile(fsoFile.Path, 1, False, &HFFFFFFFE)
Do While Not fsoTStream.AtEndOfStream
strLine = fsoTStream.ReadLine
If Left(strLine, 6) = "DW028M" Then
'read the data in the file
'match the claim num with the claim no on "DBase" col D
' if found then put the data req to the col & row on "DBase" starting at col "O"
'find the next claim and match same
End If
Loop
fsoTStream.Close
End If
Next
End Sub
Really need some help with this one, to match a record in a text file with a record on excel
I have already opened the text file & selected the correct record as per attachments, but really need to know how to match the claim no & post the values to the sheet "DBase".
This is where is starts & ends at the mo
If somebody can show me how to match the claim & get the 1st bit of data back in the sheet then i might able to carry on!
Sub ImportMatchData()
Dim FSO As Object '<-- FileSystemObject
Dim fsoTStream As Object '<-- TextStream
Dim fsoFile As Object '<-- File
Dim strLine As String
Set FSO = CreateObject("Scripting.FileSystemObject")
For Each fsoFile In FSO.GetFolder(ThisWorkbook.Path & "\").Files
If fsoFile.Type = "Text Document" Then
Set fsoTStream = FSO.OpenTextFile(fsoFile.Path, 1, False, &HFFFFFFFE)
Do While Not fsoTStream.AtEndOfStream
strLine = fsoTStream.ReadLine
If Left(strLine, 6) = "DW028M" Then
'read the data in the file
'match the claim num with the claim no on "DBase" col D
' if found then put the data req to the col & row on "DBase" starting at col "O"
'find the next claim and match same
End If
Loop
fsoTStream.Close
End If
Next
End Sub