VBA Macro that extracts data from txt file to excel based on certain criteria in a column

chriz3

New Member
Joined
Mar 28, 2017
Messages
2
Hi,

I am looking for a vba code that will open a specific text file and look for specific data. Then I want it to place that data in specified column in excel worksheet based on criteria of another column in same worksheet.

See below example from text file:

Data Report for John Smith
January 31, 2018
Report By: Portfolio
Adjusted Market Underlying
Total Market Value: 23,734 2,140
04/19/18 05:18:10 AM Page 1 of 1

Using above text example, I need code that will look for the line that begins with "Total Market Value", then return the number after the SECOND space, which is 2,140.
Then I want the code to place the number it found in column C of the excel sheet IF column A contains "John Smith".
So if John Smith was found in A11, then the 2,140 would be placed in C11.
Then I want the code to close and delete the text file.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,785
Messages
6,121,543
Members
449,038
Latest member
Guest1337

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