BrI
07-11-2017, 01:20 PM
I'm trying to extract two text strings that will have varying numbers of occurrences in a text file (uploaded a sample with two occurrences - sorry, could not upload a .txt file so put in excel text box).
The strings I want will always follow certain key words so thinking I will use variations of the code below to select the line contents after the following key words:
1) "Interest Holder Name:" - I want the bank name that follows this
2) "Document Reference:" - I want the date that follows this
strIntHlder = Trim(Split(Split(newFileContent, "Interest Holder Name:")(1), " " & vbCrLf)(0))
strDocRef = Trim(Split(Split(newFileContent, "Document Reference:")(1), " " & vbCrLf)(0))
A couple of issues:
1) I want to store all occurrences of the text strings (there can be several), can I use a loop to do this in a text file?
2) The key words will also occur in other areas in the document that I do not want to reference (not shown in the attachment). So, can I isolate a loop range - maybe to a range defined by the first and last text lines shown in the attachment?
Sorry, could not upload a .txt file so put in excel text box.
Thanks for any assistance
The strings I want will always follow certain key words so thinking I will use variations of the code below to select the line contents after the following key words:
1) "Interest Holder Name:" - I want the bank name that follows this
2) "Document Reference:" - I want the date that follows this
strIntHlder = Trim(Split(Split(newFileContent, "Interest Holder Name:")(1), " " & vbCrLf)(0))
strDocRef = Trim(Split(Split(newFileContent, "Document Reference:")(1), " " & vbCrLf)(0))
A couple of issues:
1) I want to store all occurrences of the text strings (there can be several), can I use a loop to do this in a text file?
2) The key words will also occur in other areas in the document that I do not want to reference (not shown in the attachment). So, can I isolate a loop range - maybe to a range defined by the first and last text lines shown in the attachment?
Sorry, could not upload a .txt file so put in excel text box.
Thanks for any assistance