Change specific header

Ananthak275

Board Regular
Joined
Aug 22, 2020
Messages
128
Office Version
  1. 2013
Platform
  1. Windows
  2. MacOS
I have my vba stored in another file, so when i open wb, im attaching it to a variable

Destination_file as wb

I want to go into Destination_file and look for a specific header (row 1) that has a specific string (eg "Date Address") and change it (eg "Date and Address). It has to be specific string because the column next to it is called ("Date Address ID"). How do i make sure it only changes the column with the extract string?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
VBA Code:
Sub FindAndReplace()

    Destination_file.Sheets("Sheet Name").Rows("1:1").Replace What:="Date Address", Replacement:="Date and Address", LookAt:=xlWhole

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,737
Messages
6,126,576
Members
449,318
Latest member
Son Raphon

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