View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default myCell = CStr(SomeDigits) ?

Does the entry returned by the query perhaps have a space (or some other
non-visible character) in front or after the number? You should be able to
check with the LEN function. If it is an "invisible" character of some sort,
then this VB code should uncover it...

Sub ShowASCIIvalues()
Dim X As Long
For X = 1 To Len(Selection.Value)
Debug.Print "Position: " & X & " - ASCII value: " & _
Asc(Mid(Selection.Value, X, 1))
Next
End Sub

--
Rick (MVP - Excel)


"Dick Watson" wrote in
message ...
That's exactly what I ended up doing (more or less, see another posting
for
more specifics) but I still wonder how the query gets the number stored as
text, General format, no XlNumberAsText error, no ', and yet it seems
impossible to do the same from VBA.

Thanks for replying.

"Rick Rothstein" wrote:

I think you will have to format the cell as Text. Using A1 and 123 as an
example...

Range("A1").NumberFormat = "@"
Range("A1").Value = 123