Number formatting for Europe

dracer

Board Regular
Joined
Jul 30, 2014
Messages
75
Office Version
  1. 365
  2. 2019
Hi there. I'm trying to reformat a number as follows. 101,015.15 should show as follows 101.015,15 with the decimal and the comma reversed. I was able to change the first comma to a decimal with custom number formatting, but can't seem to change the second period. Can someone send me the code if possible? Thanks!:confused:
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Maybe

Try it in a copy of your workbook

Select the cells (just one column) and run this macro

Code:
Sub aTest()
    Dim rCell As Range
    
    With Selection
        For Each rCell In .Cells
            rCell.Value = Replace(Replace(rCell, ",", ""), ".", ",")
        Next rCell
        .TextToColumns Destination:=.Cells(1), DataType:=xlDelimited, FieldInfo:=Array(1, 1)
        .NumberFormat = "#,##0.00"
    End With
End Sub

Hope this helps

M.
 
Upvote 0
Thanks. What it's doing is adding the comma before the last 2 digits, but it didn't insert a period in the place of the thousands. Eg. It's showing 100115,32 instead of 100.115,32 or 2541,14 instead of 2.541,14.
 
Upvote 0
It worked for me

Before macro

[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #DCE6F1"][/TD]
[TD="bgcolor: #DCE6F1"]
A
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
1
[/TD]
[TD]
Values​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
2
[/TD]
[TD]
101,015.15​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
3
[/TD]
[TD]
2,541.14​
[/TD]
[/TR]
</tbody>[/TABLE]


After macro

[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #DCE6F1"][/TD]
[TD="bgcolor: #DCE6F1"]
A
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
1
[/TD]
[TD]
Values​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
2
[/TD]
[TD]
101.015,15​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
3
[/TD]
[TD]
2.541,14​
[/TD]
[/TR]
</tbody>[/TABLE]


Don't know why it's not working for you:confused:

M.
 
Upvote 0
I don't know. What was the format of your numbers before? I had it set to currency with 2 digits.
 
Upvote 0
Maybe there are extraneous characters (spaces?) in your data.
See if this new version works

EDITED version
Code:
Sub aTestV2()
    Dim rCell As Range
    
    With Selection
        For Each rCell In .Cells
            rCell.Value = Replace(Replace(Replace(rCell, ",", ""), ".", ","), " ", "")
        Next rCell
        .TextToColumns Destination:=.Cells(1), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=[COLOR=#ff0000]False[/COLOR], _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(1, 1), TrailingMinusNumbers:=True
        .NumberFormat = "#,##0.00"
    End With
End Sub

M.
 
Last edited:
Upvote 0
Hi,

these formats are controlled with
- application.decemalSeparator
- application.thousandseparator
(maybe spelling mistakes)

If you want to send your xl-workbook to Europe, just do nothing. They will open with local settings and see the right format.

If you want to create a report with Euope number formating, the best might be to change temporarily the settings.

regards
 
Upvote 0
Hi,

these formats are controlled with
- application.decemalSeparator
- application.thousandseparator
(maybe spelling mistakes)

If you want to send your xl-workbook to Europe, just do nothing. They will open with local settings and see the right format.

If you want to create a report with Euope number formating, the best might be to change temporarily the settings.

regards

I'm guessing the data were extracted (copy/paste) from somewhere where the numbers use US-Style and need to be converted.

M.
 
Last edited:
Upvote 0
Still not sure. There are no extra characters. I just typed in a number. It's doesn't seem to want to put the comma there. From the code above it looks like you're replacing a comma with a blank. Maybe it something on the replace coding line?
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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