Filter Excel on multiple criteria blank rows and keep rows containing specific values

rule:

  1. delete the row which has empty cell in column1
  2. Delete the row which has only alphabets but keep the row which has single alphabet like J ,K , H etc
  3. Keep the row which has M2345.CE pattern
  4. Keep the row If numeric but not single digit. if only 1 , 5 then delete but if 460.648.55 then keep row
  5. Keep rows which has alpha numeric values- CJ098L pr T12346W etc
    output.xlsx (8.5 KB)

I am able to delete blank rows and keep .CE rows but if apply multiple criteria it’snot working . It might need Linq or VBA or regex

Hi @1a2bc346dgjk7544ebjkkbvf ,

I believe you have provided us with the Input data, Could you also provide us with the Expected Output, so that we can confirm on the logic that we would require to apply.

output (1).xlsx (9.4 KB)
Thank you for reply!
Sheet 2 has output

@1a2bc346dgjk7544ebjkkbvf ,

Maybe we could generalise with a Regex Expression for all the conditions mentioned :

OutputDT = DT.AsEnumerable.Where(Function(x)System.Text.RegularExpressions.Regex.IsMatch(x(0).ToString,"\b[A-Za-z]{1}\b|[A-Za-z]+[0-9]+|\d{2,}")).CopyToDatatable

Here, DT is the Input datatable and OutputDT is the Output datatable.

Could you try the above expression and let us know if it is working or not. Do try with different data and test it.

2 Likes

Hats off to you :slight_smile:

It worked, Thanks a lot !!

1 Like

@supermanPunch where can I learn such things ? I know simple regex to get Numeric value from pdf, etc, but not this types. Any source to update knowledge ?
TIA !

@1a2bc346dgjk7544ebjkkbvf ,

We do have tutorials here :

Also, hands on with the Regex Expression editors/testers would do a good practice :

1 Like

I will check ,Thanks !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.