Notation issue after replacing comma for a dot

gjvv

New Member
Joined
Mar 20, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello,

I import data from a system. The manual input (production) is not always the same. Sometimes they use a dot, sometimes a comma.
I need to transpose these values to numbers, for calculations.
With my code, I see 2 thing going wrong.
1. the values without decimals, stays without decimals
2. the values with a dot, are after conversions aligned to the left, and cannot be used for calculations

How can I get all values into "number" format with 1 decimal?

VBA Code:
Sub notation()

    Columns("B:B").Select

    Selection.NumberFormat = "0.00"
    
    Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=True, _
        ReplaceFormat:=True, FormulaVersion:=xlReplaceFormula2
End Sub
 

Attachments

  • Sorting.png
    Sorting.png
    42.4 KB · Views: 17

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I don't know in VBA but in Xl , multiplying by 1 or adding 0 makes a number text a real number
 
Upvote 0
Does this work?
Code:
    With Columns("b")
        .NumberFormat = "0.0"
        .Replace ".", ",", 2
        .TextToColumns
    End With
 
Upvote 0
At least acknowledging my answer would have been nice :(
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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