Excel value replace help

Hi everyone,
I have a Excel sheet and i want to replace few values from that excel. Can anyone help me how can i do that.

I need to check age column if it is 0 or - values i need to replace as “not eligible”. Can anyone help how can i do that

@Learner007

Use find/replace activity and search for 0 and match entire cell and replace with not eligible

Similarly find - and now unselect match entire cell and replace with not eligible

if not you can read the data and use linq to replace all the data

Use invoke code with dt as in/out argument of type datatable

dt.AsEnumerable.Where(function(x) CDBL(x("age").ToString)<=0).ToList.ForEach(sub(r) r("age") = "Not Eligible")

then write the dt back to excel using write range

cheers

Hi @Learner007 ,
You can try steps:
-read range to get data table
-for each row , if value <=0 → assign to “not eligible”.
rewrite back file new data table
regards,

Hi,

How about the following sample?

Condition

not Int32.TryParse(CurrentRow("age").ToString,New Int32) OrElse CInt(CurrentRow("age"))<=0

Sample
Sample20231031-5L.zip (15.0 KB)

Regards,

2 Likes

Hi @Learner007 ,
Thanks For reaching out to UiPath Community.

You cab try using a fir each loop and inside that loop. use an IF condition. Use the below code inside it and try to see the result.

If (Convert.ToInt32(row(“Age”)) <= 0) Then
row(“Age”) = “not eligible”
End If

Regards,
@pratik.maskar

I see that the ‘age’ data in the example is not a column header.

Hi,

We can read 5th row as header if start cell is A5 as the following. Can you try the above sample?

image

Regards,

1 Like

@shenyu

Did you happen to try the above approach?

are you facing any issue?

cheers

Hi @Anil_G getting this error

@Learner007

May I know what you have given

did you try "0" ?

cheers

@Anil_G i gave only 0.

Actually @Yoichi code is working fine for me

1 Like

@Yoichi Thank you. It worked.

1 Like

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