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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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