Excel Activity Filter Not Working

Excel Filter activity not working
I am trying to filter from column K, and it’s not working error says that column does not exists. because the column K don’t have fix header name, and it changes from time to time.
No it’s not working.

Hi @flashdrive07,

Can you please confirm if the column position for column K is fixed?

Thanks

@iampnkz yes, the column position is fixed.

Hi @flashdrive07,

In this scenario, first use Write Cell to update the column name, then apply the filter. After filtering, use Write Cell again to restore the original column name if the same name is required.

Thanks

@flashdrive07

you can not filter the excel by providing the index or like K. Instead of that using K or index before that follow the below steps,

  • Before Filter Excel actiivty Use Read range activity(if you not used in your workflow) and save the output in variable as dtInput
  • In Filter Excel write the below expression,
    dtInput.Columns(10).ColumnName

This will refers the K column and do appropriate actions. Check the below screenshots


Let me know if this works
Happy Automation!

1 more thing, is it possible to loop by columns?

yup.. use a for each loop as below :

foreach(DataColumn column in DtInput.Columns)
{
//do what you want to do here in this block
}

will give you a collection of DataColumn object and you can iterate in a for each loop.

@flashdrive07

Yes you can do that, for that follow the below steps,

  • Use Read range activity to read your input file and stored the output in variable as dtInput.(if already doing this step ignore)

  • Take For each activity and inside that write below expression,
    dtInput.Columns
    this will loop based on columns.

Let me know if it works!
Happy Automation.

what activity should I use?
I am using Studio X

I can’t find the for each activity in Studio X.
the filter is already ok.

Can you look for loop or for each loop activity.

As normal how you are looping for arrays or lists same activity you can use here as well

Try below steps,
Go to activities panel
Clicking settings icon
Enable the show developer option.
After that go to activities panel and search for for each activity

Let me know if it works