The files I am comparing have names in column A of both workbooks. I am having trouble with the advanced editor to get this done.
Hi @jenn.d
You have two sheets like Sheet1 and Sheet2. Then you want to compare Sheet1 values with Sheet2. which are unique in both sheets you want to write to the new sheet.
If my understanding is correct then follow the steps, here we are using LINQ Expressions,
→ Use the Read range workbook activity to read the Sheet1 and store in a datatable called dt1.
→ Use another Read Range workbook activity to read the Sheet2 and store in other datatable variable called dt2.
→ Then create another datatable variable called Output_dt.
→ Then use the below LINQ Expression in assign activity,
- Assign -> Output_dt = dt1.AsEnumerable.Where(Function(X) dt2.AsEnumerable.Any(Function(Y) X("ColumnA").Equals(Y("ColumnA")))).CopyToDataTable()
→ Use the Write Range workbook activity to write the Output_dt to the Sheet3 in your excel.
Hope it helps!!
1 Like
Hi @jenn.d ,
Detailed Steps
- Create Variables:
- Create two
DataTable
variables:dtWorkbook1
anddtWorkbook2
. - Create a
Boolean
variable to indicate if a match is found:matchFound
.
- Read Data from Workbooks:
- Use the
Excel Application Scope
to open the first workbook and theRead Range
activity to read the data intodtWorkbook1
. - Repeat the process for the second workbook and read the data into
dtWorkbook2
.
- Compare Data:
- Use a
For Each Row
activity to iterate throughdtWorkbook1
. - Inside the loop, use another
For Each Row
activity to iterate throughdtWorkbook2
. - Compare the values in column A (assuming the first column is indexed as 0).
- Log Results:
- Use an
If
activity to check if the names match. - Log the results using the
Log Message
activity or store the results in another DataTable or list for further processing.
Regards
Sandy