C
Coder1215
Hi,
I'm using excel 2007 and 2003. I have a routine to loop trough *.txt
files in a folder and search for string in a single line. All was fine
until I had to, based on found value, take all lines from this value
to top, e.g. When I find a line marked with specyfic marker ("in this
case "NC") I have to take all values from over this value until I
reach empty line (so looping backwards), then I continue searching.
Code samples (below function to copy data to specyfic cells)
Function move_all(LineofText, k)
Cells(k, "a") = Mid(LineofText, 2, 2)'Here if
Mid(LineofText, 2, 2) = "NC"
'macro should go back and pull all data until it reaches
empty line.
Cells(k, "b") = Mid(LineofText, 6, 8)
Cells(k, "c") = CLng(Mid(LineofText, 17, 10))
Cells(k, "d") = Str(Mid(LineofText, 29, 15))
Cells(k, "e") = CStr(Mid(LineofText, 46, 38))
Cells(k, "f") = CStr(Mid(LineofText, 86, 4))
Cells(k, "g") = Mid(LineofText, 91, 18)
Cells(k, "h") = Trim(Mid(LineofText, 100, 20))
Cells(k, "i") = Mid(LineofText, 125, 8)
Cells(k, "a").Activate
End Function
Thanks in advance for help
Regards
Piotr
I'm using excel 2007 and 2003. I have a routine to loop trough *.txt
files in a folder and search for string in a single line. All was fine
until I had to, based on found value, take all lines from this value
to top, e.g. When I find a line marked with specyfic marker ("in this
case "NC") I have to take all values from over this value until I
reach empty line (so looping backwards), then I continue searching.
Code samples (below function to copy data to specyfic cells)
Function move_all(LineofText, k)
Cells(k, "a") = Mid(LineofText, 2, 2)'Here if
Mid(LineofText, 2, 2) = "NC"
'macro should go back and pull all data until it reaches
empty line.
Cells(k, "b") = Mid(LineofText, 6, 8)
Cells(k, "c") = CLng(Mid(LineofText, 17, 10))
Cells(k, "d") = Str(Mid(LineofText, 29, 15))
Cells(k, "e") = CStr(Mid(LineofText, 46, 38))
Cells(k, "f") = CStr(Mid(LineofText, 86, 4))
Cells(k, "g") = Mid(LineofText, 91, 18)
Cells(k, "h") = Trim(Mid(LineofText, 100, 20))
Cells(k, "i") = Mid(LineofText, 125, 8)
Cells(k, "a").Activate
End Function
Thanks in advance for help
Regards
Piotr