Using TRIM with Char(32)

sparky2205

Active Member
Joined
Feb 6, 2013
Messages
476
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi folks,
I have 2 pieces of data that are both amalgamations of data from other sheets on the same workbook in the following way: =A1&"/"&B1&"/"&C1
The data is:
A1 FOC01/FOCAL POINT/C and B1 FOC01/Focal Point /C
The difference being the extra space in B1
This is just a sample of the data. There are a couple of hundred lines.

What I am trying to achieve:
Compare both columns of data for differences in the data but ignore spaces and case.

What I've done:
=SUBSTITUTE(A1,CHAR(32),"")=SUBSTITUTE(B1,CHAR(32),"")
Basically remove the spaces and compare what's left. But it always returns FALSE.
I've checked and that extra space is definitely Char(32)
But I've also tried:
=SUBSTITUTE(A1,CHAR(160),"")=SUBSTITUTE(B1,CHAR(160),"") - same result i.e. FALSE

TRIM does not work and all data is formatted as General.

Any ideas?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about
=LOWER(SUBSTITUTE(A1," ",""))=LOWER(SUBSTITUTE(B1," ",""))
 
Upvote 0
Hi Fluff,
alas I've already tried that too. Same result, FALSE.
 
Upvote 0
That works on the test strings you provided, if your split the formula into 2 cells do the results look the same?
 
Upvote 0
Hi Fluff,
I typed my compare values directly into a new worksheet and of course, it worked.
When I check my original data: A1 FOC01/FOCAL POINT/C and B1 FOC01/Focal Point /C
A1 actually has 3 trailing spaces.
So what I've realised is I have a mix of char(160) spaces and char(32) spaces so I've had to account for both.
This is what I've come up with and it works:
=IF(SUBSTITUTE(SUBSTITUTE(A1,CHAR(160),""),CHAR(32),"")=SUBSTITUTE(SUBSTITUTE(B1,CHAR(160),""),CHAR(32),"")=TRUE,"Ok","Check")



Thanks for your help.
 
Upvote 0
Solution
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,824
Messages
6,121,783
Members
449,049
Latest member
greyangel23

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