How to delete one space in the end of cell?

Nuutti

New Member
Joined
May 25, 2016
Messages
7
I have multiple tabs witd data. On some cells there seems to be one space in the end of cell. How can I remove it? Best option would be to remove that last space on all tabs at once, but also help how to remove them on single tab would help.

I have already tried simple TRIM, but it leaves the last single space in the end cell in some cells.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try this:
Code:
Sub Trim_Me()
Dim c As Range
Dim i As Long
Application.ScreenUpdating = False
    For i = 1 To Sheets.Count
        For Each c In Sheets(i).UsedRange
            c.Value = RTrim(c.Value)
        Next
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
@My Aswer Is This

Just a heads up that the Trim function will not remove Char(160) from a string.

igold
 
Upvote 0
Not sure what Char(160) is. The OP wanted it trimmed and I tested it and it trimmed all spaces from the end when I tested it. I saw no request to trim Char (160) what ever that is. Thanks for your input.
@My Aswer Is This

Just a heads up that the Trim function will not remove Char(160) from a string.

igold
 
Upvote 0
Char(160) is a non printing space character that occasionally gets used.

Which could be why the OP posted this:

I have already tried simple TRIM, but it leaves the last single space in the end cell in some cells.

and Toranaga replied with this answer:

Try
=SUBSTITUTE(A1,CHAR(160),"")
or
=SUBSTITUTE(A1,CHAR(32),"")

You may have tested it but I guarantee you if any of his cells had CHAR(160) on the end as opposed to CHAR(32), we would not be having the conversation right now... You may want to research this out.

igold
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,108
Members
452,302
Latest member
TaMere

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