How to keep null terminated in text transformation?

Ok, like this:

I have an Excel file in .xlsx

. One of the cells contains the value 132,6

and the format is the number. This means Excel shows the number as 132,60

. Now, since it represents a price (132 € and 60 cents), I would like to keep it in this format 132,60

.

enter image description here

Now I need to convert all cells to text format for purposes that are not important in this question. Since the value is valid 132,6

, after conversion it is the displayed text value instead of 132,60

. But I would like to keep the trailing zero when converting it to text.

Is there a VBA implementation for this?

+3


source to share


1 answer


this format should work

=TEXT(A2;"#'##0.00")

      



EDIT: IN VBA
Below snippet converts numbers in selection to text.

Sub aMacro()
  Dim SelRange As Range
  Set SelRange = Selection
  For Each c In SelRange.Cells
     c.Value = Format(c.Value, "###0.00")
  Next
End Sub

      

+4


source







All Articles