VBA, Substitute, Find and Replace, Trim Not working to remove space

CM_1995

New Member
Joined
Jan 7, 2025
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All;

I have a file and the numbers have a blank space at the end of the character.

I have tried trim, substitute, macros and find and replace to remove this but nothing works.
e.g.
=SUBSTITUTE(E5," ","")
=Trim(CLEAN(E3))
=Value(e5)

Sub Replace_Example1()
Range("E3:J78").Replace What:=" ", Replacement:=""
End Sub

Sub
Worksheets("Sheet1").Columns("E").Replace _ What:=" ", Replacement:="", _ SearchOrder:=xlByColumns, MatchCase:=True
End Sub

I have also tried changing the format from "general" to "number" and copying and pasting the results of the formulas as values.

Note:
- all functions work to remove or replace " "on text that is placed alongside side the numbers in the same file but not the numbers themselves.
-Find and replace works when one single cell is highlighted at a time.
- no error notification appears to allow me to "convert to number"

Example Data.xlsx
DEFGHIJ
2Total to be delivered 2018/2019 2019/2020 2020/2021 2021/2022 2022/2023
3Example data 114 8 2 1 12
4Example data 21 0 1 0 0 0
5Example data 310 2 1 1 1 1
6Example data 44 3 0 0 0 1
7Example data 511 4 1 1 1 1
8Example data 6120.53 100 0 0 0 0
9Example data 760.22 0 5 5 5 5
10Example data 81 0 0 0 0 1
11Example data 93 0 1 1 1 0
12Example data 101 0 0 0 1 0
13Example data 114 4 0 0 0 0
14Example data 121 1 0 0 0 0
15Example data 13100 75 0 0 0 0
16Example data 14100 75 0 0 0 0
17Example data 154 1 1 1 0 0
18Example data 161
19Example data 174 2 0 0 0
20Example data 1810 2 1 1 1
21Example data 19100 50 0 0 0
22Example data 20300 0 50 50 50
23Example data 218 1 1 1 1
24Example data 228 1 1 1 1
25Example data 2316 2 2 2 2
26Example data 2420 3 3 3 3
27Example data 2515 3 2 2 2
28Example data 268 1 1 1 1
29Example data 278 1 1 1 1
30Example data 2832 4 4 4 4
31Example data 2910 2 1 1 1
32Example data 3075 5 10 10 10
33Example data 314 1 1 0 0
34Example data 3210 2 1 1 1
35Example data 33100 50 0 0 0
36Example data 34300 0 50 50 50
37Example data 358 1 1 1 1
38Example data 368 1 1 1 1
39Example data 378 1 1 1 1
40Example data 3816 2 2 2 2
41Example data 3920 3 3 3 3
42Example data 4012 2 2 2 2
43Example data 418 4 2 2 0
44Example data 4264 5 10 10 10
45Example data 4310 1 2 2 2
46Example data 4420 2 2 2 5
47Example data 455 1 2 0 0
48Example data 462 1 1 0 0
49Example data 473 0 0 1 1
50Example data 488 0 2 2 2
51Example data 492000 0 750 750 0
52Example data 502000 0 0 750 750
53Example data 514 0 1 1 1
54Example data 524 0 1 1 1
55Example data 534 0 1 1 1
56Example data 5414 2 2 2 2
57Example data 55100 0 0 50 50
58Example data 5624 3 3 3 3
59Example data 578 0 0 2 2
60Example data 583 2 0 0 0
61Example data 5930000 0 7500 7500 7500
62Example data 604 1 1 1 1
63Example data 612000 0 0 750 750
64Example data 628 8 0 0 0 0
65Example data 631 1 0 0 0 0
66Example data 641 1 0 0 0 0
67Example data 65370 250 20 20 20 20
68Example data 665 0 5 0 0 0
69Example data 674 2 0 0 0 2
70Example data 683 2 1 0 0 0
71Example data 698 4 1 1 1 1
72Example data 708 4 1 1 1 1
73Example data 7110 2 1 1 1 1
74Example data 72110 0 60 10 10 10
75Example data 734 4 0 0 0 0
76Example data 745 5 0 0 0 0
77Example data 7510 2 2 2 2 2
78Example data 7620 0 2 2 2 2
Sheet1
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try
ActiveSheet.UsedRange.Replace What:=ChrW(8203), Replacement:="", LookAt:=xlPart

And if that doesn't work
ActiveSheet.UsedRange.Replace What:=ChrW(160), Replacement:="", LookAt:=xlPart
 
Upvote 0
Solution
If neither of Alex's suggestions work, you can use a formula to diagnosis the rouge character(s) as follows:
Book1
EFGH
514 149
6452
7 160
Sheet2
Cell Formulas
RangeFormula
G5:G7G5=MID(E5,SEQUENCE(LEN(E5)),1)
H5:H7H5=UNICODE(G5#)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,225,327
Messages
6,184,296
Members
453,227
Latest member
Slainte

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