Applying a Filter in Excel with Multiple Critera

John12

New Member
Dear All,

I am new to bluepism and this is my first post!

I have managed to create a custom Excel object which includes the filtering feature. However It works well when only a single criteria is used, I am attempting to filter only records that have "Failed" written, or that have blank values in the field of interest using the following code:

Code:
Dim worksheet as Object
Worksheet = GetWorkbook(handle, Nothing). ActiveSheet
worksheet.UsedRange.AutoFilter (Field:= fieldToBeFiltered,  Criteria1:=criteriaToFilter, Operator:=2, Criteria2:="=")

However when running the process showing Excel output, only the "Blank" cells are being selected to be filtered:


sm2GgokHT42WhCE4XgFn_Filter-M.jpg


How can I proceed to use more than one criteria please?
 

gil.silva

Active Member
Hello John12,

I would say this isn't RPA question, rather a VB.Net.
Anyway, it seems to me that the code is correct. It might be some problem with the input.
Did you try to hardcode your filter 'Failed' in the code to see if it works?
 

John12

New Member
Thank you gil.silva for guiding me in the right direction! I noticed that I had an extra "=" sign in the input.
 
Top