PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 9, 2022

[FIXED] How do I change decimal dot into decimal comma?

 August 09, 2022     decimal, excel, separator, vba     No comments   

Issue

I have a column containing numbers with mixed decimal separators.
example

I need to use "," as separator.

How do I change dot into comma?

With ThisWorkbook.Worksheets("RAW").Range("A1")
    .Value = Replace(.Value, ".", ",")
End With

The point is stored as text
look at it

Is there any way to store it as general/numeric?

I tried this

With ThisWorkbook.Worksheets("RAW").Range("A1")
    .NumberFormat = "General"
    .Value = Replace(.Value, ".", ",")
    .NumberFormat = "General"
    .Value = .Value
End With

Solution

A single cell could be solved quick and dirty through:

.Value = Replace(.Value, ".", ",")*1

Or:

.Value = CSng(Replace(.Value, ".", ","))

If you happen to have a range to process, you could use:

Sub Test()

With ThisWorkbook.Worksheets("RAW").Range("A1:A3")
    .Replace ".", ","
    .TextToColumns
End With

End Sub

Per column:

Sub Test()

With ThisWorkbook.Worksheets("RAW").Range("C2:D4")
    .Replace ".", ","
    For Each col In .Columns
        col.TextToColumns
    Next
End With

End Sub


Answered By - JvdV
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing