Decimal comma

ReeveCZE

New Member
Joined
Jun 8, 2014
Messages
7
Hi,

I have a sheet full of numbers, but I need to change their format to my native (that is Czech) where we use a decimal comma instead of a decimal point. Otherwise, my Excel won't add up or substract the data.

If I perfom the following code manually, it works.
Code:
Selection.NumberFormat = "0.00"
   
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
If I use this code in a Sub(), it will leave me with all the data set as "number saved as text" and the option to convert it into number.

I would really appreciate any help. Thanks in advance.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Yes, that's the second part of the code. Works manually, not in a macro... it really replaces the dots with commas, but somehow messes up the cell format...
Code:
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ReplaceFormat:=False
 
Last edited:
Upvote 0
maybe you can try this one on a dummy of your sheet.

Code:
Sub TextRangeToNumbers_incolumn_A()
'Made by Datsmart 14-07-2006 on mr Excel
    Dim Rng As Range
    Dim c As Range
'Change Column A referrence as needed
    Set Rng = Range("A1:A" & Range("A1500").End(xlUp).Row)
    On Error Resume Next
'Cycle through each item in Rng, Trim value then add zero
    For Each c In Rng
        If c.Value <> "" Then
            Application.WorksheetFunction.Trim (c.Value)    'Trim removes any spaces
            c.Value = c.Value + 0   'Adding 0 changes item to number
        Else
        End If
    Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,999
Messages
6,122,645
Members
449,093
Latest member
Ahmad123098

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