All Records.xlsb | ||||
---|---|---|---|---|
C | D | |||
3 | Sanjay Gulati Musafir | Sanjay Gulati Musafir | ||
Sheet2 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D3 | D3 | =SUBSTITUTE(SUBSTITUTE(C3," ","",LEN(C3)-LEN(SUBSTITUTE(C3," ","")))," ","",1) |
I don't know what is possible with the OP's data but your formula seems to only allow for a single leading space (not more, not less) and a single trailing space (not more, not less). If that were the case, this would do the same jobCheck this -
22 10 10.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | For info, trailing spaces in col A | To show no trailing spaces in col B | |||||
2 | Big Dog | Big Dog | 0 | Dog | |||
3 | Big Dog | Big Dog | 2 | Dog | |||
4 | Big Black Dog | Big Black Dog | 4 | Dog | |||
5 | Big Dog | Big Dog | 1 | Dog | |||
Trim Left & Right Only |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B5 | B2 | =LET(s, SEQUENCE(LEN(A2)),c,MID(A2,s,1),ts,TEXTSPLIT(TEXTJOIN("|",1,IF(c=" ","",s)),"|")+0,MID(A2,MIN(ts),MAX(ts)-MIN(ts)+1)) |
E2:E5 | E2 | =RIGHT(B2,3) |
Hi Sanjay, thanks for your post.Check this -
All Records.xlsb
C D 3 Sanjay Gulati Musafir Sanjay Gulati Musafir Sheet2
Cell Formulas Range Formula D3 D3 =SUBSTITUTE(SUBSTITUTE(C3," ","",LEN(C3)-LEN(SUBSTITUTE(C3," ","")))," ","",1)
Function LRTRIM(s As String) As String
LRTRIM = RTrim(LTrim(s))
End Function
MikeJ100.xlsm | ||||
---|---|---|---|---|
A | B | |||
1 | ||||
2 | Big Dog | Big Dog | ||
3 | Big Dog | Big Dog | ||
4 | Big Black Dog | Big Black Dog | ||
5 | Big Dog | Big Dog | ||
Trim Left & Right Only (2) |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B5 | B2 | =LRTRIM(A2) |
That gives us nothing to go on.Sadly, Peter's suggestion doesn't work.
If you are using the formulae I gave or @Peter_SSs gave there are negligible chances of getting error. But still if you are telling, it means there is some problem somewhere.I have updated my account details. I am using 365 and Windows. Sadly, Peter's suggestion doesn't work.