Find and replace 0 with 1 in an excel file, the activity replaces all the occurrences of 0

When we are trying to find and replace 0 with 1 in an excel file, the activity replaces all the occurrences of 0.

e.g. cell value 101 becomes 111

the expected output is

if cell value is 0 then only it should replace it to 1

BOT should skip the other cells which having the values like 11005, 40, 100, 909, etc

in For each row if we use row(“column name”). contains(“0”) is working but due to large number of rows it is taking too much time which is not desirable.

Hi @sharad.bodke

You can try like this

Note: Check the Match entire cell contents property

I/P:
image

O/P:
image

Hope this helps!!

1 Like

Hi @sharad.bodke ,
Can you clear your requirements?
eg : 101 → 111
If cell is 201 , 501, 10001,…
what will be it?
regards,

@sharad.bodke

Dt1=DT1.AsEnumerable.Select(Function(row) DT1.clone.LoadDataRow({If(row(0).ToString.Equals(“0”),“1”,row(0).ToString)},False)).CopyToDataTable

Its working fine now.

Thanks

1 Like

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