Home

Excel formula help

adie_105
New Contributor

Hi

I am novice. And hope someone can help.

I have numbers in the range of 1 to 90 spread in 2 adjacent columns.

Some numbers can appear in both and either or both cells can be empty

Each cell can have up to about 10 entries separated by semicolons

I need to count the no of rows where a number appears in either column between a range of for example 50 – 80

Hope that makes sense.

I have become stuck because of the semicolons.

For example

20;33;55;79                            1;20;55

4;54                                          

37                                              63;67

                                                   29;35;45

11;43;44                                     45;49

 

Number of rows =3

 Is there a formula you could give me or can you point me in the right direction of how to do it myself?

Thanks for any help.

Glenn

3 Replies

Hi,

 

It's easier to do with Power Query, but if with formula that could be for data like this

image.png

we could add helper column C with formula

=(SUMPRODUCT((VALUE(
   TRIM(MID(SUBSTITUTE(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1),";",REPT(" ",99)),
         (ROW(OFFSET($A$1,,,LEN(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1))-LEN(SUBSTITUTE(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1),";",""))+1))-1)*99+
         ((ROW(OFFSET($A$1,,,LEN(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1))-LEN(SUBSTITUTE(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1),";",""))+1)))=1),99))) >$F$1)*
   (VALUE(
   TRIM(MID(SUBSTITUTE(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1),";",REPT(" ",99)),
      (ROW(OFFSET($A$1,,,LEN(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1))-LEN(SUBSTITUTE(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1),";",""))+1))-1)*99+
      ((ROW(OFFSET($A$1,,,LEN(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1))-LEN(SUBSTITUTE(IF(ISBLANK(A1),"0",A1)&";"&IF(ISBLANK(B1),"0",B1),";",""))+1)))=1),99))) <$F$2))
  >0)*1

where TRIM part converts combination of two cells into array. When we compare first TRIM with min range, second one with max range, multiplication gives AND condition and SUMPRODUCT calculates how many numbers within the string are in the range. Finally return 1 if more than one or zero otherwise.

 

After that only to SUM all cells in columns C.

See details in attached file. Power Query variant is also here (second sheet). 

Hi Sergei

Just tried it out and works perfectly. Thank you very much for the formula and speedy response. Have decided to gain a better understanding of excel and i guess the best place to start would be the Microsoft site with YouTube as a back up. Thank you again.

 

It's hard to say what is the best, that's always a combination and depends on situation. There are a lot of resources, small part is mentioned here https://techcommunity.microsoft.com/t5/Resources-and-Community/Little-list-of-some-cool-Excel-websit...

 

Microsoft support pages are better if to understand how this or that function works. For the patterns google helps to find them, I guess 99% of questions we have are already solved by someone, very often with explanations and variants of the solution. In a while you understand which resources are most suitable for you.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies