Invisible "?" in Strings

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
464
So I'm not even sure what the best way to describe this is but...

I have a string value in Excel. In the excel sheet it reads as "4502575223". If I click at the end of this string and type backspace, the cursor will not move. If I press it again, it deletes the 3 off the end. It takes 2 backspaces because there is an invisible "?" both before AND after the string.

How do I know there are invisible "?"? Well in VBA, in the locals window, i see this:

[TABLE="width: 500"]
<tbody>[TR]
[TD]Expression[/TD]
[TD]Value[/TD]
[TD]Type[/TD]
[/TR]
[TR]
[TD]Current_ship_po[/TD]
[TD]"?4502575223?"[/TD]
[TD]String[/TD]
[/TR]
[TR]
[TD]Current_ship_line[/TD]
[TD]"100.1[/TD]
[TD]String[/TD]
[/TR]
</tbody>[/TABLE]


if I do the following code, the result is false:

Code:
 If Left(current_ship_po, 1) = "?" Then current_ship_po = Right(current_ship_po, Len(current_ship_po) - 1)
FALSE

Code:
 If Left(current_ship_po, 1) = "" Then current_ship_po = Right(current_ship_po, Len(current_ship_po) - 1)
FALSE

Code:
 If Left(current_ship_po, 1) = " " Then current_ship_po = Right(current_ship_po, Len(current_ship_po) - 1)
FALSE

I need to get rid of the "?" on both sides of the string but I can't even get the machine to recognize it's there. Anybody seen this before? How do I code through this mess? Thanks guys!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Re: Invisible "?" in Strings (help!!! my mind!!!)

in a blank cell enter
=CODE(A2)
where A2 is the cell containing your string, what does it return
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

Or in code use AscW(current_ship_po) to determine the character number.
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

Hi,
I don't know about Vba but using the trim funcion =trim(string) usually removes any surplus spaces, including leading or trailing, in a string. Maybe you can incorporate in the fomula in your code.
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

Hi,
I don't know about Vba but using the trim funcion =trim(string) usually removes any surplus spaces, including leading or trailing, in a string. Maybe you can incorporate in the fomula in your code.

Trim doesn't work sadly.
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

Or in code use AscW(current_ship_po) to determine the character number.


So after I set the current_ship_po variable to that string with the "?" I ran it through AscW(current_ship_po).

The result was "8237".
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

In that case if you want to get rid of it in the sheet use
Code:
Sub chk()
Range("A:A").Replace ChrW(8273), "", xlPart, , , , False, False
End Sub
Change range to suit
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

Or in the string
Code:
Current_ship_po = Selection
Current_ship_po = Replace(Current_ship_po, ChrW(8273), "")
 
Upvote 0
Re: Invisible "?" in Strings (help!!! my mind!!!)

In that case if you want to get rid of it in the sheet use
Code:
Sub chk()
Range("A:A").Replace ChrW(8273), "", xlPart, , , , False, False
End Sub
Change range to suit

So I did the below as you suggested (I think):

Code:
  LAST_SHIP_ROW = .Columns(1).Find("*", , , , xlRows, xlPrevious).Row            
            For X_ROW = 2 To LAST_SHIP_ROW
                        .Range("O:O").Replace ChrW(8273), "", xlPart, , , , False, False
                        current_ship_po = .Cells(X_ROW, ship_po).Value


But this doesn't seem to fix it. The variable current_ship_po is still a string equal to "?4505275223?".



Code:
LAST_SHIP_ROW = .Columns(1).Find("*", , , , xlRows, xlPrevious).Row            
            For X_ROW = 2 To LAST_SHIP_ROW
                        current_ship_po = .Cells(X_ROW, ship_po).Value
                        current_ship_po = Replace(current_ship_po, ChrW(8273), "")

But this doesn't seem to fix it. The variable current_ship_po is still a string equal to "?4505275223?".
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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