Convert number to text format VBA

Solved
ph412 Posted messages 49 Status Member -  
ph412 Posted messages 49 Status Member -
Hello,

I’m looking to convert a number into text format.
I’ve searched a lot of forums and every time I keep getting the same result:
I can transform most of my numbers but not all of them: let me explain

The number 5.5 will become 5.5 in text
but the number 2.375 will become 2375 and in numbers
So it considers the comma (only in the second case) as a thousand separator and doesn’t change its format...

It’s incomprehensible

For this, I use the following loop twice:

For a = 2 To 25
Worksheets("XX").Range("AI" & a).Select
Worksheets("XX").Range("AI" & a) = "" & Worksheets("XX").Range("AI" & a)
Next

But I’ve tried with CStr() and it’s the same

Thank you very much to the community!

1 answer

f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
 
Hello,

to convert a number cell to text:

Worksheets("XX").Range("AI" & a).NumberFormat = "@"

like this:

but the number 2.375 will become 2375 and in numeric form I think it's related to your decimal separator which may not be a comma.
0
ph412 Posted messages 49 Status Member
 
Hi!
Thanks, it works well but I would like to have the label "Number Stored as Text" that appears once I have made this transformation and that's what I want to obtain without my separator issue.
0