Find values in TXT file and replace with Excel cells

Santy4Tas

New Member
Joined
Jun 2, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hello dear friends,

I'm looking for a macro to find and replace values in a txt file.

The txt file is located in the route D:\Template\info.txt

This file looks like this
The current date and time is: %time%

GPU1 Temperature is: %GPU1T%
GPU1 Fan Speed is: %GPU1F%
GPU1 RPM are: %GPU1R%

GPU2 Temperature is: %GPU2T%
GPU2 Fan Speed is: %GPU2F%
GPU2 RPM are: %GPU2R%

and the Excel file looks like this
Screenshot.jpg


What I need is a macro that can find and replace the following:
Find %time% and replace with the value of cell G2
Find %GPU1T% and replace with the value of cell A2
Find %GPU1F% and replace with the value of cell C2
Find %GPU1R% and replace with the value of cell E2
Find %GPU2T% and replace with the value of cell B2
Find %GPU2F% and replace with the value of cell D2
Find %GPU2R% and replace with the value of cell F2

After that, of course save the file but in a NEW location which is D:\GPUReport
but with the same name info.txt

I hope someone can help me with this.

Thank you so much in advance!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
What else is in your text file, if nothing else you would best using via to write values to a new text file for each line of your workbook
 
Upvote 0
What else is in your text file, if nothing else you would best using via to write values to a new text file for each line of your workbook
To be honest actually the file has a html code, I synthesized the information with the example I put to not make it too dense
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

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