Excel "Replace" is unreliable

davidam

Active Member
Joined
May 28, 2010
Messages
497
Office Version
  1. 2021
Platform
  1. Windows
Hello
Does anyone have a simple explanation as to why the Edit/Replace works only part of the time. I use it to create multiple formulas by first concatenatiting the formulas with ^ where I will want = , then Copy and PasteValues, and then use Edit/Replace to replace ^ with =. It works beautifully dozens of times and then suddenly Excel cannot find either ^ or =. Is there some way to correct this issue?
Thanks,
David
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I am assuming that you are talking about the CTRL+H Find and Replace dialog, not the REPLACE worksheet function.

One possible explanation is that the settings in the OPTIONS part of the FIND AND REPLACE dialog have been changed, for example the "Match entire cell contents" box has been ticked. Excel remembers these preferences permanently when they are changed.
 
Upvote 0
Excel remembers these preferences permanently when they are changed.
To add to Hamburgler's statement above...

Excel remembers these preferences permanently when they are changed even if those preferences were changed inside via VB Replace method used inside a macro, event code or a UDF (yes, a UDF).
 
Upvote 0
I believe LookIn, LookAt, MatchByte, and SearchOrder persist from the UI or a VBA Find to subsequent Finds. The other parameters do not.

MatchCase presists from the UI to subsequent UI Finds, but not to VBA.

More maliciously, Replace with workbook scope persists from the UI to VBA (it's not otherwise an option in VBA), and you have to do a dummy Find to correct the behavior.
 
Last edited:
Upvote 0
I am using the REPLACE worksheet function. I suspect that that the "remembering" is the issue as I do us lookat and lookin in some vba functions. In the last instance, the issue cleared up when I rebooted.
I will experiment with this in the near future.
Thanks to All.
 
Upvote 0
Finally this issue is resolved for me. As Hamburgler suggested, all I had to do was check the options dialog on the Worksheet replace function and uncheck 'entire cell contents' . Yes, it does get re-checked by VBA functions that employ Lookat:=xlWhole (which, by the way, is absolutely essential when using VBA Find).
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

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