Getting the Count of a variable in a certain column

Hi guys,

In order to create my program as efficient as possible. I’m wondering if there is a way to find the total amount an item excists in a column.

For example i have a column with over 200 different variations of numbers. And i need to know how many cells contain a certain number i’m searching for. With out iterating trough the entire column. Cause the data set is way to large to do this everytime.

The real life example is that i have a list with 100 application numbers. And i need to find the quantity that application is mentioned in a certain excel sheet. I already made a list of those application numbers to filter them out. But now i need to find a way to check how many times each list item excists in this large column.

To make this work with for each & if loops is not that hard. But this is a smal part of a verry large program i need to find a more efficient way to solve this. Hopefully has the anwser to this. But i can’t seems to find it.

If you guys have any suggestion dont hesitate to discuss them :smile: with me!

Thanks in advance.
Kind Regards,

let’s say that col is the name of the variable that you get from read column. then, String.Join(" ",col).Count(function(x) x=“123”) will return the number of "123"s in your string.

1 Like

I do believe this is what i’m looking for, thanks for guiding me in the right direction!

But this returns “0” for everyvalue. Did i interpet a part wrong of this function?

EDIT: I debugged this part. And the Join function works, it outputs an entire string of my values. So i’m guessing the function (x)x does do what it is supposed to on the string value.

try using this system.Text.RegularExpressions.Regex.Matches(String.Join(" ",col), item).Count


Works like a charm. Thanks for help, i really apriciate it!

1 Like

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