Forum Discussion

VShostak's avatar
VShostak
Copper Contributor
Nov 06, 2023

macro VBA excel change cell format

Hello!

 

In my macro, I used code to replace "." on ",". However, during this replacement, the cell format changes to text. How can I write code to ensure that the format remains as a number?

 

Selection.NumberFormat = "@"
For Each c In Selection
c.Value = Replace(c, ".", ",")
Next

 

 

9 Replies

    • VShostak's avatar
      VShostak
      Copper Contributor
      Now they change "." on space " " instead ",".
      Сan you tell me how to write the code correctly.
      • VShostak 

        Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?

Resources