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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
What result(s) do you get when you enter =CODE(LEFT(A1)) and =CODE(RIGHT(A1)) ?

Change A1 to suit.
 
Upvote 0
Well 160 isn't actually a space and TRIM won't be able to deal with it.
 
Upvote 0
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
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,214,378
Messages
6,119,188
Members
448,873
Latest member
jacksonashleigh99

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