Can I use invoke method to replace value in Column A if Column B contains certain Value in it?

For Example

in Image if Status Column Contain “FineOLD” then Replace Number in Category Column with “Ready”

I don’t want to use loops here for some reason.

Is there any other ways to replace the values in Datatable without using Loops?

image

Hi @Kathiravan
You can use invoke code for this case :slight_smile:

assume you had stored the excel in datatable variable dt1

in invoke code pass the dt1 as argument with direction as in/out

in the code write like this

dt1.AsEnumerable().Where(Function(row) row(“Status”).ToString.Equals(“FineOLD”)).ToList().ForEach(Sub(r) r(“Category”)=“Ready”)

Now write the dt1 to excel again

Thanks & Regards,
Nived N

1 Like

Hi,

FYI, another solution:

image

dt = dt.AsEnumerable.Select(Function(r) dt.Clone.LoadDataRow({if(r("Status").ToString.Contains("FineOLD"),"Ready",r("Category").ToString),r("Status").ToString},False)).CopyToDataTable

Regards,

2 Likes

Thanks a Lot for your Support Yoichi. Both works Great :slight_smile:

Thanks a Lot for your Support @NIVED_NAMBIAR , It works Great :smiley:

1 Like

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