I want to use variable instead of hard-coated value in the value field. Because I want to filter the field which has the values like 0540, 0673, 1134, etc. So instead of using the numeric value I want to declare it in a variable so that I should write each filtered value in different sheets of excel file.
You are already reading the datatable in first read range workbook. Why are you using another Read range workbook inside the For each. May I know the reason.
I believe you want to seggregate the data based on a column and write to different sheets…
If that is the requirement…then use this dt.AsEnumerable.GroupBy(function(x) x("ColumnToFilterOrGroup").ToString).ToDictionary(function(x) x.Key,function(x) x.CopyToDatatable ).ToArray in the for loop in property …
And inside loop use currentItem.Value as datatable to write the data into each sheet
Use row(“ColumnName”).ToString in the value column in the Filter Wizard.
But what are you really trying to do here? This code will run the Read Range FilterUsingDataTable.xlsx and Filter Data Table for every row in Input_Branch_File.xlsx - and I’m not sure what the goal of that is.
First read range workbook has only input_branch codes in column A name: input_branch.
2nd Read Range Workbook inside the loop is the actual data which has to be filtered matching the input_branch criteria.
I want to use the input_branch code from the first read range and instead of placing the numeric value in the value field in Filter Data Table Wizard, I just want to declare a variable so that my code became generic.
I want to copy the code that is 0540 and want to use this code in the value field of Filter Wizard. So that instead of typing each input_branch code manually, I want to use the variable. Thanks,
You don’t use “ColumnName” exactly, you replace it with the column you want to use for your filter value from InputBranchDT.
But again, why do you have another Read Range inside the For Each Row? That will execute the Read Range for every row in InputBranchDT. You don’t want to do that.
Read Range FilterUsingDataTable.xlsx into DT_FilterUsingDataTable. Do that before the For Each Row. Then in your filter, set FilterUsingDataTable as the source, use row(InputBranchDT_column).ToString as the value in the filter, and set it the out datatable to DT_Filtered.
Now every time it loops, you’ll get a datatable DT_Filtered that is filtered from DT_FilterUsingDatatable.
@postwick : Thank you very much for your swift response but pl see the below screenshot which shows the Filter Wizard details. Actually I want to read the Input_Codes from a separate excel file and then use that codes one by one in the filter wizard value section so that due to this I will free from entering the manual value in the filter criteria. That’s why I used two Read Range activity.