Home » excel » excel – Convert decimal separator from ',' (comma) to '.' (dot) e.g. "7,5" to "7.5"

excel – Convert decimal separator from ',' (comma) to '.' (dot) e.g. "7,5" to "7.5"

Posted by: admin May 14, 2020 Leave a comment

Questions:

Yes. I know. Those are localization settings…

But I wont tell my client to change localization settings for just my app.

So how to convert those numbers? Or how to change number formatting for given range. (Need dots there, user may input comas or dots, or even numbers where commas just separate like 1,000,000.00 …)

EDIT:
Circumvented whole issue by CStr(), and passing on the strings.

How to&Answers:

If this is purely for display purposes then you can use custom format strings on the cells. Then your users can continue to use their localization settings that they are used to for inputting numbers. I think that changing localization settings would be a bad idea, as then your client may enter numbers incorrectly.

This is the general way of formatting numbers using custom format strings.

╔═════════════╦══════════════════════════╦═══════════════╗
║ To display  ║            As            ║ Use this code ║
╠═════════════╬══════════════════════════╬═══════════════╣
║ 1234.59     ║ 1234.6                   ║ 

Answer:

#.# ║ ║ ║ ║ ║ ║ 8.9 ║ 8.9 ║ #.000 ║ ║ ║ ║ ║ ║ 0.631 ║ 0.6 ║ 0.# ║ ║ ║ ║ ║ ║ 12 ║ 12 ║ #.0# ║ ║ ║ ║ ║ ║ 1234.568 ║ 1234.57 ║ #.0# ║ ║ ║ ║ ║ ║ 44.398 ║ 44.398 ║ ???.??? ║ ║ 102.65 ║ 102.65 ║ ???.??? ║ ║ 2.8 ║ 2.8 ║ ???.??? ║ ║ ║ (with aligned decimals) ║ ║ ║ ║ ║ ║ ║ 5.25 ║ 5 1/4 ║ # ???/??? ║ ║ 5.3 ║ 5 3/10 ║ # ???/??? ║ ║ ║ (with aligned fractions) ║ # ???/??? ║ ╚═════════════╩══════════════════════════╩═══════════════╝

And here is a link to the Microsoft information on regional format strings

(updated link 11-aug-2016)

https://support.office.com/en-gb/article/Create-or-delete-a-custom-number-format-78f2a361-936b-4c03-8772-09fab54be7f4