Replace dot to comma

Hello,

I’m trying to modify the numbers in a column, replace a “.” by “,” :
examlple 12345.23 => 12 345,23

I’m using a VBA code xlWorkSheet.Range(“J:J”).NumberFormat = “(* #,##0.00);(* (#,##0.00);(* “”-”“??);(@_)”

till the moment it does 12 345.23 but not replacing the “.” by “,”

Hi @abdel,

Try below code
yourValue.ToString().Replace(".",",")

Regards,
Arivu

3 Likes

i want it in the following code:

Dim xlApp As Microsoft.Office.Interop.Excel.Application = Nothing
Dim xlWorkBooks As Microsoft.Office.Interop.Excel.Workbooks=Nothing
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook=Nothing
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet =Nothing
Dim xlWorkSheets As Microsoft.Office.Interop.Excel.Sheets =Nothing

xlApp= New Microsoft.Office.Interop.Excel.ApplicationClass
xlApp.DisplayAlerts=False
xlWorkBooks=xlApp.Workbooks
xlWorkBook=xlWorkBooks.Open(PathToExcel)
xlApp.Visible = False

xlWorkSheets= xlWorkBook.Sheets
xlWorkSheet= CType(xlWorkSheets(1), Microsoft.Office.Interop.Excel.Worksheet)
xlWorkSheet.Range(“J:J”).NumberFormat = “(* #,##0.00);(* (#,##0.00);(* “”-”“??);(@_)”

xlWorkBook.Save
xlWorkBook.Close

Hello,

I use your solution but if appear a negative value in excel i got below error

System.indexoutofrangeException