G
Guest
Hello again! I am searching within a text file for the last row within the
file. After I locate the row I need to separate the data and place into
multiple cells on my worksheet. The code I have is as follows:
Dim TextPath As String
Dim DelimSrchChar As String
Dim METtime As String
Dim DataBuffer As Variant
Dim NCData As Variant
Dim DelimPos As Integer
'===============================================
DelimSrchChar = ","
TextPath = "C:\Temp\Formatted_NC_SN1008.txt"
Open TextPath For Input As #1 'open text file for SN1008
Do While Not EOF(1) 'go while not end of text file
Line Input #1, NCData
If EOF(1) Then
DelimPos = InStr(NCData, DelimSrchChar)
MsgBox DelimPos
Application.Cells(1, 2) = NCData
End If
Loop
Close #1
End Sub
NCData looks like this: 000:03:42:53,3.40426,20.,18.9623. I can get the
data, but I am having trouble finding a method for parsing the data and
placing the parsed data into multiple cells.
The problem: I can use the InStr function to get the data to the left of
the first delimiter as position 13 (i.e. 000:03:42:53) , but how can I get
the data between delimiter positions 13 and 21 (i.e. 3.40426) and between
delimiter positions 21 and 26 (i.e. 20.XX), and to the right of delimiter
position 26 (i.e. 18.9623)? The data sizes can change so they are not
necessarily fixed.
Thanks you.
D.Parker
file. After I locate the row I need to separate the data and place into
multiple cells on my worksheet. The code I have is as follows:
Dim TextPath As String
Dim DelimSrchChar As String
Dim METtime As String
Dim DataBuffer As Variant
Dim NCData As Variant
Dim DelimPos As Integer
'===============================================
DelimSrchChar = ","
TextPath = "C:\Temp\Formatted_NC_SN1008.txt"
Open TextPath For Input As #1 'open text file for SN1008
Do While Not EOF(1) 'go while not end of text file
Line Input #1, NCData
If EOF(1) Then
DelimPos = InStr(NCData, DelimSrchChar)
MsgBox DelimPos
Application.Cells(1, 2) = NCData
End If
Loop
Close #1
End Sub
NCData looks like this: 000:03:42:53,3.40426,20.,18.9623. I can get the
data, but I am having trouble finding a method for parsing the data and
placing the parsed data into multiple cells.
The problem: I can use the InStr function to get the data to the left of
the first delimiter as position 13 (i.e. 000:03:42:53) , but how can I get
the data between delimiter positions 13 and 21 (i.e. 3.40426) and between
delimiter positions 21 and 26 (i.e. 20.XX), and to the right of delimiter
position 26 (i.e. 18.9623)? The data sizes can change so they are not
necessarily fixed.
Thanks you.
D.Parker