trimming cells

rlocher

New Member
Joined
Oct 4, 2007
Messages
15
ok, there is probably an easy solution here, but I can't figure it out. I need to remove the trailing "spaces" in some cells but I don't think they're really spaces. TRIM or CLEAN doesn't work. I tried LEN(SUBSTITUTE(A1," ","")) to count the number of characters without spaces and it's counting something other than text. Text to columns (space or tab delimited) doesn't work - it separates by spaces between words, but not the ones after. I still have blank space after the text. First question, if they're not spaces, what are they? Secondly, how do I trim the unwanted junk after the text? Of note, these are city/town names so spaces need to be kept between words - just not after. Any ideas?
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Copy one of these spaces (just the space) and paste it into a spare cell (say H1). What does this return

=CODE(H1)
 

rlocher

New Member
Joined
Oct 4, 2007
Messages
15

ADVERTISEMENT

I get #VALUE!
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hmm. You would get that if H1 was blank. Maybe you didn't manage to copy the space (it can be tricky).

In H1 enter

=RIGHT(A1,1)

where A1 has text with a trailing space. What does the CODE formula return now.
 

rlocher

New Member
Joined
Oct 4, 2007
Messages
15

ADVERTISEMENT

I think you were right.

Now I'm getting 32
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Curiouser and curiouser.

Code 32 is a regular space so I don't understand why none of the methods that you've tried have worked.

Edit

Can you try

=LEFT(A1,LEN(A1)-1)

Does that remove the space.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,991
Messages
5,514,655
Members
409,013
Latest member
metrognome

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top