Hi @Raja.G ,
Best and easiest solution would be to use Linq queries only as mentioned by @ppr and @Sudeen_Raj_Shetty
If you are new to this concept - I am giving you the step-by-step details and few minor points to be considered while using the regular expressions
Only 6 steps are involved for this
- Open the excel file where you need to apply the filter
- Read the data table and store to a variable (dtTable)
- Assign new data table variable (example dtvalid) with below regular expression as mentioned above. Make sure you have imported System.Text.RegularExpression in your project imports
dtvalid =
(From d In dtTable.AsEnumerable
Let v=d(1).ToString.Trim
Let chk =System.Text.RegularExpressions.Regex.IsMatch(v, “(^00[234]\d{4}$) | ([1]\d{4}$)”)
Where chk
Select r=d).CopyToDataTable
- Assign new data table variable (example dtinvalid) with below regular expression as mentioned above. Only difference to make is in where condition. Where chk=false
dtinvalid =
(From d In dtTable.AsEnumerable
Let v=d(1).ToString.Trim
Let chk =System.Text.RegularExpressions.Regex.IsMatch(v, “(^00[234]\d{4}$) | ([2]\d{4}$)”)
Where chk=false
Select r=d).CopyToDataTable
- Write data table to required sheets
