0

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
3
  • I got error: Type Mismatch :( Commented Nov 28, 2020 at 14:21
  • yeah, sorry. just typo Commented Nov 28, 2020 at 14:28
  • @JvdV could you please look at my answer below? Commented Nov 28, 2020 at 14:59

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

ok but I get error: "Microsoft Office Excel can convert only one column at a time. The range can be many rows tall but no more than one column wide. Try again by selecting cells in one column only" how to iterate through multiple columns?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.