Replace one text with another

MadBern

New Member
Joined
May 10, 2019
Messages
37
Hey folks,

Is this possible?
I want a particular word to be replaced by a different word in the same cell as it's written in.

Example: If someone in cell A1 types "Apples" I want the text automatically change to "Fruits".

I've tried Conditional formatting and Data validation without success.
I get to respond correctly if I type in a number, f.ex. "1" and it changes to "Fruits", but not if I type in any kind of text.
 
OK, in a module try this short code:

Code:
Sub enableEvents()
    Application.enableEvents = True
End Sub

Run that then re-try the apples in cell A1.
 
Last edited:
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
does the macro run? you can check this by placing a breakpoint
 
Upvote 0
That worked, thanks a bunch!
Now I only have to make it do that for every cell in a spesific range.
 
Upvote 0
That worked, thanks a bunch!
Now I only have to make it do that for every cell in a spesific range.

What range do you want it applied to ? and is it JUST for the word "apples"?
 
Upvote 0
Hey folks,

Is this possible?
I want a particular word to be replaced by a different word in the same cell as it's written in.

Example: If someone in cell A1 types "Apples" I want the text automatically change to "Fruits".

I've tried Conditional formatting and Data validation without success.
I get to respond correctly if I type in a number, f.ex. "1" and it changes to "Fruits", but not if I type in any kind of text.


This can be done for all instances of Apples

Choose File -> Options -> Proofing -> Autocorrect options

In the "replace" field type Apples, in the "with" field type fruits

This will automatically change it from apples to fruits when entered
 
Upvote 0
This can be done for all instances of Apples

Choose File -> Options -> Proofing -> Autocorrect options

In the "replace" field type Apples, in the "with" field type fruits

This will automatically change it from apples to fruits when entered

Whilst that is an alternative it is case-sensitive and will change every newly entered cell where "Apples" is inputted, to "fruits", which may not be desired!

EDIT: It appears case-sensitive for me at least, as it works on "Apples" but not "apples" (?) :LOL:
 
Last edited:
Upvote 0
Whilst that is an alternative it is case-sensitive and will change every newly entered cell where "Apples" is inputted, to "fruits", which may not be desired!

EDIT: It appears case-sensitive for me at least, as it works on "Apples" but not "apples" (?) :LOL:

Yes, true it is certainly not ideal
 
Upvote 0
Range: A1:F30
And yes, it should apply only to that one word.

OK for a range A1:F30 try the following code: (note i am using phone atm so can't actually test it! If it does not work and you don't have a solution already i can type one up at home when I get to my PC)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim iSect As Variant
Set rng = Range("A1:F30") 
Set iSect = Application.Intersect(rng, Target) 
    If iSect Is Nothing Then
        'do nothing
    Else
        If UCase(Target.Value) = "APPLES" Then
            Target.Value = "Fruits"
        End If
    End If
End
 
Upvote 0

Forum statistics

Threads
1,215,891
Messages
6,127,603
Members
449,388
Latest member
macca_18380

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