Formula to remove excessive spacing

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,964
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hello all,

I couldn't find an answer through the search function so here goes.

Is there a formula-based way (non-VBA) to reduce excessive spacing to just 1 space ? For instance:

ABC (6 spaces)DE

would result in:

ABC (1 space)DE

All cells contain plain text and the formula will be in a different area. I want to avoid VBA and if possible Lambda functions. Probably we need an array formula.
When there are multiple instances of excessive spaces in a cell, it's fine to have them all converted.

Many thanks !

Wim
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Am I missing something in the example I would use
=TRIM(A1)
 
Upvote 0
It's also in the middle of the string ;)
 
Upvote 0
Yep, and TRIM will remove excess spaces in the middle of the string as well.....but are they really spaces
Have you tried using
=CLEAN(A1) as well
 
Upvote 0
Solution
Oh, I didn't know/forgot about, that one ! I assumed Trim would take away leading and trailing spaces but leave anything in the middle untouched.
I'll experiment a bit because the actual case is more involved than only this part but thanks for pointing me to this.
 
Upvote 0
Works good and it explains why I couldn't find difficult array formulas or Lambda functions for it, it's just the TRIM function :biggrin:
 
Upvote 0
Sometimes we don't see the forest for the trees....:):)
 
Upvote 0
I assumed Trim would take away leading and trailing spaces but leave anything in the middle untouched.
Perhaps you were thinking of the vba Trim() function that works that way.
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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