In the excel there is two sheets sheet1 has one column names as “Service No” and sheet two has “Service Number”. In this i want match this both column value and if the value is not matched then the data row should be remove.
Please help regarding this.
Welcome to the community
Follow the steps
- Create a new table dt3 and then use dt1.clone() in an assign activity
- Loop through dt2
- Inside loop use a filter datatable and filter dt1 on the
currentrow("service number").tostring
… and get to filterdt - Use a merge dstatable to merge filterd rows filterdt to dt3
At the end of loop dt3 will have only the matching rows
Cheers
you can do this in multiple ways. you can achieve using LINQ, if you are not much familiar with LINQ. you can achieve it using below steps
- Read both sheets and keep in 2 data tables
- loop for all values in sheet 1
- in loop use lookup data table activity provide service number of sheet 1 and check in sheet 2 is available or not.
- Based on the response you can delete in sheet 1 dt or create a new data table(dt) to capture the required data
Happy Automation!!!
how we can delete the data from sheet1 ?
could you please help me with linq query ?
Hi @shailesh1920 ,
Could you provide us with a Sample Input data and the Expected Output for that data ?
It will be easier for us to understand logic needed and suggest you the approach accordingly.
Above sheet having “Service Number” Column and below sheet having “Service No” Column if the service number not matched with below sheet then that row should be remove from below sheet.
Please help on this.
Could you try the below Steps :
-
Read the above sheet’s First Column using
Read Column
Activity. Assuming that theService Number
will always start from that specific position (A2). The Output will be a collection which will contain all the service numbers present in the column, let the output variable be named asserviceNoList
. -
Next, Read the below Sheet using
Read Range
Activity. Get the Output as Datatable, sayDT
. -
Next, Use an
Assign
Activity and use a Linq Query to Filter only the rows which contains the Service numbers present in the above sheet.
DT = DT.AsEnumerable.Where(Function(x)serviceNoList.Any(Function(y)y.ToString.Trim.Equals(x("Service No").ToString.Trim))).CopyToDatatable
- After the Filtering, The
DT
variable should contain only the rows that has the service numbers which match the service numbers in the above sheet. We could then Write this datatable value to a new sheet usingWrite Range
Activity.
To handle the Errors on Direct CopyToDatatable
you could check the below post :
Let us know if you are still facing issues.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.