Find the number of cells

good afternoon
I would like to know the number of cells
for example I have this data
A1 = name
A2 = last name
A3 = number
A4 = address

I would like a result like this to be thrown at me: 4
If there are 5 cells that boat: 5

Is there any way to do that?

I will assume this is in excel. First you should use a read range activity on the file and save to a datatable variable (i’ll call it dt1). Now you can get the number of cells by using dt1.rows.count

NOTE: This assumes you only have cells in a single column. If you have multiple columns and you want to count all the cells that are not blank/empty within excel, that would be a bit more involved.

1 Like

dt1.rows.count = I will keep this information

I want to know the number of cells for the “oden de pedido” column
The result of the number of cells is 5

Is there a way to do this process?

@borismh

Dt.Rows.Count.ToString

If you want to count the number of cells in a specific column of a datatable that are not blank/empty, you can use the following:

dt1.AsEnumerable().Where(function(r) Not(String.IsNullOrWhiteSpace(r.Item("oden de pedido").ToString))).Count

This uses linq/lambda. How it works is that it converts all of the rows in the column “oden de pedido” to string, then checks to see if that row is null, blank, or has whitespace characters only. This is all contained in a .Where() statement, so it only selects datarows where the expression to the right of the Where statement is true. Since I put the Not() operator at the beginning, it is grabbing all datarows that are NOT blank, empty, or whitespaces. Then it counts how many rows were grabbed and returns it as an integer.

1 Like

@Dave


And how do I apply that term? excuse

@borismh you can use an assign activity and assign an integer variable on the left side, then put the above expression on the right side.

@Dave

Thank you

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