Trailing space issue

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
Hi, the below code removes trailing spaces, but for some reason it does not remove space from this, i clicked F2 and the space is still there, why does it work on some but not others?

<TABLE style="WIDTH: 60pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=80 border=0><COLGROUP><COL style="WIDTH: 60pt; mso-width-source: userset; mso-width-alt: 2925" width=80><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl63 style="BORDER-RIGHT: #f0f0f0; BORDER-TOP: #f0f0f0; BORDER-LEFT: #f0f0f0; WIDTH: 60pt; BORDER-BOTTOM: #f0f0f0; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=80 height=17>98956P102 </TD></TR></TBODY></TABLE>

Code:
Sub test()
With ActiveSheet.UsedRange
    .Value = Evaluate("if(" & .address & "<>"""",trim(" & .address & "),"""")")
End With
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
What result(s) do you get when you enter =CODE(LEFT(A1)) and =CODE(RIGHT(A1)) ?

Change A1 to suit.
 
Upvote 0

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
What result(s) do you get when you enter =CODE(LEFT(A1)) and =CODE(RIGHT(A1)) ?

Change A1 to suit.

Formula returns 160 for RIGHT
Formula returns 32 for LEFT
 
Upvote 0

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
Well 160 isn't actually a space and TRIM won't be able to deal with it.
 
Upvote 0

rconverse

Well-known Member
Joined
Nov 29, 2007
Messages
1,187
Can't you use find " " and replace with ""?
 
Upvote 0

Ron Coderre

MrExcel MVP
Joined
Jan 14, 2009
Messages
2,316
Try this....
Select the range of cells to be impacted

From the Excel Main Menu:
Edit.Replace
...Find what: Hold down ALT...type: 0160...Release ALT
...Replace with: ...leave this area blank...
Click: Replace All

Does that help?
 
Upvote 0

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
Try this....
Select the range of cells to be impacted

From the Excel Main Menu:
Edit.Replace
...Find what: Hold down ALT...type: 0160...Release ALT
...Replace with: ...leave this area blank...
Click: Replace All

Does that help?

Awsome, that worked, now how can incoporate this into a code?
 
Upvote 0

Forum statistics

Threads
1,191,718
Messages
5,988,272
Members
440,146
Latest member
rgomes8

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
Top