Search Text file for cell value then replace regex match in text file from cell value 7 columns over from first match

meirbabboon

New Member
Joined
May 5, 2015
Messages
7
I am attempting to use a macro to open a text file and search for a match in column d then when the match is found look back in the text file for the MAC address and replace it with the cell value 7 columns over from first match. I will post examples of what I am trying to do.

Step 1. look at active sheet range D3:D13
Step 2. find hostname (range D3:D13 of excel file) in text file
Column D - HostnamesColumn K - MAC Addresses
ST999WAP20074-E0-A9-0B-68-31
ST999WAP201
ST999WAP100DC-72-E5-E5-09-0C
ST999WAP101A2-E9-87-03-3F-9E
ST999WAP10269-E1-76-FC-B7-4E

<tbody>
</tbody>

Step 3. Replace the generic MAC (AA-BB-CC-DD-EE-FF) in text file with the matching row (column 7) from hostname search

ap6522 AA-BB-CC-DD-EE-FF
use profile ap6522
use rf-domain st999
hostname st999wap200
ip default-gateway 1.1.1.1
interface vlan1
ip address 1.1.1.2/22


ap6522 AA-BB-CC-DD-EE-FF
use profile ap6522
use rf-domain st999
hostname st999wap100
ip default-gateway 1.1.1.1
interface vlan1
ip address 1.1.1.3/22

ap6522 AA-BB-CC-DD-EE-FF
use profile ap6522
use rf-domain st999
hostname st999wap101
ip default-gateway 1.1.1.1
interface vlan1
ip address 1.1.1.4/22

ap6522 AA-BB-CC-DD-EE-FF
use profile ap6522
use rf-domain st999
hostname st999wap102
ip default-gateway 1.1.1.1
interface vlan1
ip address 1.1.1.5/22

Step 4. Save Text file with replacements

Any assistance would be greatly appreciated. If this could be a button that I can add to the sheet that would be great.
 

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).

Forum statistics

Threads
1,214,944
Messages
6,122,387
Members
449,080
Latest member
Armadillos

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