Count of a column in excel

Hi team,

I would like to store the count of a column in excel in a variable and I would like to store the count of column B (105) in a variable.

Hi @Matthew2

Please use the below LINQ function to get particular Column count.

DtTable.Rows.Cast(Of DataRow)().Where(Function(row) Not row.Item("ColName") IsNot DBNull.Value Or row.Item("ColName").ToString() <> "").Count

1 Like

Hi @Matthew2

What I have understood is you want the rows count of column B from your datatable if it so.
TestDt is the datatable name(output of the read range activity)
TestDt.AsEnumerable().Select(Function(x) (x(“YourColumnName”)).ToString).ToArray().Count

1 Like

Hi @Matthew2 ,

Use below expression to get column count from datatable


1 Like



If you want to get a particular column data count use Read Column activity which will return the output in Ienumerable(Object). Later you can use the variable (Ex : OutCountcolumn.count).

Same way, if you want entire the datatable column count you can use (Yourdatatable.columns.count)


1 Like

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