How to have a rounding to 2 digits after the decimal point in excel

I tried this method but i have an issue
image

@Soudios - if you are reading that value as string and you want to keep that as is, try that first one…if you are reading as string and use it as double value then use the second…

image

1 Like

@prasath17

What i need is to change the numbers on colum “C” in Excel file to 2 decimal
You method is working with all the colum ?

But you didn’t show any numbers as of now…

Yes. when you loop it and you can apply for all the column values…

1 Like

That’s why i have read column activity and after i use format value

@Soudios - Personally, I haven’t tried that activity.

I would read the sheet and convert the column value either For each or Using Linq and write it back…this is my approach…

1 Like

@prasath17
can u send me your approch plz (sample)

@Soudios - This is what I was thinking…

Here Row(2) is my Column 2 values…

Then Outside the loop use the write range to write the results back to the sheet.

Hope this helps…

1 Like

@prasath17
it will not takes a lot of time ? because il have 200.000 rows on my excel file

Then you need LINQ query for that…Give me few mins…

Going forward, please put that in your requirement clearly so that it would take help us.

1 Like

@Soudios - Here you go…

image

Invoke Code

dt.AsEnumerable().ToList().ForEach(Sub(row) row(2)= Math.round(cdbl(row(2)),2))

Invoke Code Arguments

As I said before, use write range to write to your results after that.

1 Like

It’s not better to use read column or it will execute that for all the excel ?

It will update all the column c values. Before asking the question first please try the solution and see what it is doing

1 Like

See my screenshot again.

1 Like

@prasath17

Perfect it works !!! Thank you

But can u explain me how the bot focus on column “C”, i want to know if i will use it next time plz

@Soudios - row(0)= A
Row(1)= B
Row(2)= C…So instead of giving Row(“ColumnName”)…I used Row(2), that’s all…

Once you done with your testing, please mark my post as solution as it help others…Thanks…

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.