For each row of a data table

Hi all,

How can I do a for each row activity that only works for a row that contains specific word/character?


1 Like

HI @jasperlzx,

Use for each row activity
use if Condition

if true do your operations else leave it go to next record.




Can you be a bit more specific? The word/character can be in any column or a specific column?

If it’s a specific column, you can put an If activity inside the For Each Row activity and put the following condition:


If it’s any column, inside the For Each Row you can put a For Each activity and iterate through datatable.Columns and inside this loop put the If activity with the following condition:


, where ‘column’ is the current iteration of the datatable.Columns loop.

If you want to extract all rows that meet this condition and only iterate through these for further processing, you can use LINQ to obtain the rows:

datatable.AsEnumerable().Where(Function(x) x.Item("ColumnName").ToString.Contains("word")).ToArray


hi, this does not work.

hi, its usually in column A. its every 6/7 row after one other but I do not have column header

You can also give it the column index if you don’t know the column name. If it’s the first column then the index is 0:


@jasperlzx If you are aware of which column you need to look into, you can filter your data table and get only rows that have required value and then loop through only those rows for further processing.

filteredRows = yourDataTable.Select(“[Column_Name] like '%” + Character/WordToCheck + “%'”)

user for each to loop through filtered rows

1 Like

can U show an example? I don’t have a column name as the column also contains data that are not related.

Here’s an example: (8.3 KB)

@jasperlzx Is its possible to share the data in excel and specify what you are looking in that?

sorry I can’t share the file. I just need to location the word, “employee name”, and take the 6 rows till the next “employee name”. thanks.

@jasperlzx Here you go (7.8 KB)

Hi some one help me to do the same for a number instead a word for the above case. i used filter wizard and able to achieve this. but i would like to try with For each and if. Example : student record. specific column name : Age.
for all the rows where age is more than 10 , then a specific sequence need to get executed.

I created variable as “Age” data type string. then if condition didn’t allow to use Age>10. since 10 is different data type.

If i use int32 or double same error while comparing in IF

if you are trying to compare within the for each loop, try checking
(Convert.ToInt32(row(“Age”).ToString) > 10)

1 Like

Hi how would I sort if I am just looking for rows that Start with 4 Alphanumeric charcters

this worked :slight_smile: