Extract extra spaces at the end of text in a cell

reneev

Board Regular
Joined
Apr 26, 2017
Messages
53
So, our payroll system doesn't know how to properly space text in a report to be exactly how long the word or words are therefore we have to estimate the spacing to be x number of spaces. Which means if the word or words are shorter than x number, the rest of the field contains spaces.

For example, if we set the the full name field to 20 characters then the following name would come out like this (where ^ are extra spaces).

Doe, John F^^^^^^^^^ (11 actual characters and 9 spaces at the end).

This makes it difficult to use the data elsewhere without manually deleting the extra spaces or using the Text to Columns function then Concatenating everything back together.

This happens for all fields in our reports however it's only a real problem with text because number fields usually have a set number of characters (dates, SS#, etc...)

Is there a better way to strip those extra spaces?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
you can use trim to remove spaces except the ones between words
Code:
=TRIM("text to trim   ")
 
Upvote 0
Hi,

This is what Scott means:


Book1
ABCDEFG
1Doe, John F 20Doe, John F11
Sheet16
Cell Formulas
RangeFormula
C1=LEN(A1)
E1=TRIM(A1)
G1=LEN(E1)


I'd imagine you'd need to insert a column next to the data to be trimmed, then use the new column's data for your other calculations; however, if you can't do that, then you'll need a VBA solution.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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