VBA Solution for Parsing Information from Text file

jakeman

Active Member
Joined
Apr 29, 2008
Messages
325
Office Version
  1. 365
Platform
  1. Windows
Hi all - I'm looking for a VBA solution to parse information from a text file. The text file is exported out of an old system that formats the data in a kind of report format, not in a table format which would make my life much easier. Currently, the process is that I open the .txt file and search for an account number (#XN12345) and the copy all of the rows attributed to that account number and then paste them into a separate spreadsheet. I've tried a Power Query solution already for this but it doesn't work correctly because my .txt file is not arranged in a table format but in a report format.

So, that being said. My ideal solution would be something like this:

1. Search for account number "XN12345"
2. When found, return the very next row of data all the way down to the break in the line for that account which takes place where the text reads "Totals for detail entries."
3. Copy the entire range of values and return them to a new spreadsheet

Any help provided would be appreciated.

Thank you!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi all - I'm looking for a VBA solution to parse information from a text file. The text file is exported out of an old system that formats the data in a kind of report format, not in a table format which would make my life much easier. Currently, the process is that I open the .txt file and search for an account number (#XN12345) and the copy all of the rows attributed to that account number and then paste them into a separate spreadsheet. I've tried a Power Query solution already for this but it doesn't work correctly because my .txt file is not arranged in a table format but in a report format.

So, that being said. My ideal solution would be something like this:

1. Search for account number "XN12345"
2. When found, return the very next row of data all the way down to the break in the line for that account which takes place where the text reads "Totals for detail entries."
3. Copy the entire range of values and return them to a new spreadsheet

Any help provided would be appreciated.

Thank you!
Please provide an example of your text file.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top