Macro to Replace only the first time a Word apears in cells ina column?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I've been trying to do a simple find and replace down Column AQ but i'm running into problems because sometime the words i'm trying to replace are pearing again. in the same cell

So wjay I what to do is find "What Time Started" and replace with "Begin Time".

the problem is the cells might have two or three lots of "What Time Started"? can I get it to only replace the first One?

Tony
 

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).
Dim rng$
rng = Range([AQ1], Cells(Rows.Count, "AQ").End(xlUp)).Address
Range(rng) = Evaluate("substitute(" & rng & ",""What Time Started"", ""Begin Time"",1)")
 
Upvote 0
Oh Dear,
Sorry Footoo, but I've just realised this is not working
it is simply taking the data in column AQ1 replacing and coping it down the page>
I need a macro to replace the first example of the word in each row

can anyone help please

Tony
 
Upvote 0
Oh Dear,
Sorry Footoo, but I've just realised this is not working
it is simply taking the data in column AQ1 replacing and coping it down the page>
I need a macro to replace the first example of the word in each row

can anyone help please

Tony

Sorry. Should have tested it. Try this :

Code:
Dim rng$
rng = Range([AQ1], Cells(Rows.Count, "AQ").End(xlUp)).Address
Range(rng) = Evaluate("INDEX(substitute(" & rng & ",""What Time Started"", ""Begin Time"",1),)")
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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