YasserKhalil
Well-Known Member
OK my tutor. My real data has no ? character
Then why not just use the code from post#2?my need is no LOOP
I really liked it and considered it the first and the most perfect solution.Then why not just use the code from post#2?
OK my tutor. My real data has no ? character
I can't figure out any workround, it just seems that VBA can't handle/interpret that value for some reason.
You're welcome & thanks for the feedback.Thank you very much for your great contribution and for your first solution
Best Regards
What I meant, but didn't say very well, wasAs the character is coded with two bytes so the classic VBA way is a loop using Replace & ChrW …
I can't think of a workround that uses Range.Replace, without a loop.
Thank you very much Mr. Marc
Sub Demo2()
Dim V, R&, B() As Byte, C&
With Range("B1", [B1].End(xlDown))
V = .Value2
For R = 1 To UBound(V)
B = StrConv(V(R, 1), vbFromUnicode)
For C = 0 To UBound(B)
If B(C) = 63 Then B(C) = 32
Next
V(R, 1) = StrConv(B, vbUnicode)
Next
.Value2 = Application.Trim(V)
End With
End Sub
With following codeI really liked it and considered it the first and the most perfect solution.
My target now is to know why replace failed with the whole column (why with this character specially)??
You have told there may be a workaround as for that ..
Dim i As Long
For i = 1 To Len(Selection.Value)
Debug.Print i & ")." & Asc(Mid(Selection.Value, i, 1)) & "-" & AscB(Mid(Selection.Value, i, 1)) & "-" & AscW(Mid(Selection.Value, i, 1))
Next i
1).84-84-84
2).104-104-104
3).97-97-97
4).110-110-110
5).107-107-107
6).115-115-115
7).32-32-32
8).97-97-97
9).32-32-32
10).108-108-108
11).111-111-111
12).116-116-116
13).32-32-32
14).63-64-1600
15).63-64-1600
16).63-64-1600
17).32-32-32
18).70-70-70
19).111-111-111
20).114-114-114
21).32-32-32
22).72-72-72
23).101-101-101
24).108-108-108
25).112-112-112
But this doesn't work for me at all (I tried in both samples)
Can you give me this line of code please to try on my side.So give a try to the Range.Replace method with its parameter MatchByte set to True …
Can you give me this line of code please to try on my side.
Range.Replace ChrW(1600), "", xlPart, , , True
Sub findmethod()
Range("B1:B20").Replace ChrW(1600), "", xlPart, , , True
End Sub
If b(c) = 220 Then b(c) = 32