SUBSTITUTE function - 3 digit Problem, only checks first 2 digits.

phililpB

New Member
Joined
Feb 12, 2018
Messages
3
Hello,

I'm using substitute nested many times to turn formulas with cell references into equations with text. It's a multipart process starting with a formula-to-text function generating a secondary array, some other stuff, and then a huge string of nested substitute functions generating a third array with the equations.

However, substitute seems to only reference the first two digits regardless of what i do.

For instance running =SUBSTITUTE(SUBSTITUTE(E8,"c14"," yes"),"c144", "no") on two cells, one with c14 and one with c144 properly returns yes for the first, but for the second returns yes4. So it seems to be only evaluating the first two digits, falsely recognizing the second cell as "c14" replacing that and leaving the additional 4.

Is there a solution to this problem? Any help would be greatly appreciated.
 

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).
I don't really know what your goal is here, but have you tried flipping the arguments?
=SUBSTITUTE(SUBSTITUTE(E8,"c144"," no"),"c144", "yes")
 
Upvote 0
Hi Max,

One thing. It's c14 vs c144. You have c144 two times, but maybe that's a typo.

Good point though! Maybe having it evaluate 3digit numbers first will sort it out.

However, if already painstakingly constructed my monster nested statement. If there was a way to salvage it and get it to evaluate correctly that would be icing on the cake.
 
Upvote 0
Yea, that was a typo. I'm not sure of a better way to do this without looking at your full nested formula
 
Upvote 0
You have to consider the order the functions are performed.

The Innermost functions go first...

So it goes like this
if E8 - c144
=SUBSTITUTE(SUBSTITUTE(E8,"c14"," yes"),"c144", "no")
=SUBSTITUTE(SUBSTITUTE("c144","c14"," yes"),"c144", "no")

c14 does exist in the string "c144", so substitute returns " yes4"
=SUBSTITUTE(" yes4","c144", "no")

c144 doesn't exist within the string " yes4", so substitute then returns " yes4"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,983
Members
452,540
Latest member
haasro02

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