You are here:

# Excel/counting recurring pairs and threesomes in a table

Question
38   31   32   21   22   27   10   16
34   11   15   30   10   36   16   19
4   21   17   27   28   30   25   6
9   24   31   29   19   28   5   15
4   5   15   35   7   38   30   1
32   34   19   2   11   23   10   39
1   19   45   34   17   32   38   22
25   32   10   16   34   9   40   44
42   23   20   18   32   40   33   3
2   13   40   15   11   26   30   32
10   26   35   32   25   27   12   16
31   20   12   38   43   7   25   6
8   33   20   5   11   29   28   38
43   30   26   42   32   17   12   6
20   34   26   14   9   13   18   23
in this table of lotto numbers there are a few pairs of numbers:
10,16 in rows 1,2, 8 & 11
4,30 in rows 3,5;
32,40 in rows 8,9 & 10 and 6,12 in rows 12 & 14.
I want to find the occurrence of pairs 1 with 2 to 45; 2 with 3 to 45; 3 with 4 to 45 etc on all the lines of the table.  Counting the occurrence of each number is easy via COUNTIF of the table but finding the number of pairs that occur across the table is proving difficult.  in this subset of the table I should be able to find 4 examples of 10 with 16 but I fail dismally - maybe age is catching up on me (75ys old).  I'm trying to find out if there is a normal distribution of pairs or whether there are some that occur more frequently.

Dave

Age isn't catching up with you, but you did have a difficult problem to solve - it took me a while to come up with a solution - which you can find at http://www.aidanheritage.byethost3.com/excel/Lottery_Pattern_Check.xls - I've BASICALLY turned the multiple columns into ONE value using a helper column, which I can then use a multiple condition countif formula (using a trick with SUMPRODUCT - the double negative signs convert the logical true/false values into 1 for true and 0 for false).  I've laid it out as a grid, but it could equally be done as a series of rows - which you would need to do if you wanted to check it three ways.  HOPEFULLY the sheet is clear enough to follow to adapt as you need, but do let me know if I can help further.
Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment Oh my god (OMG!) what a solution! it works brilliantly but I doubt I would have ever come up with that answer although I was tying to program a 45x45 table. I have already extended to cover many more rows of numbers. Dave

• Ask a Question
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Aidan Heritage

##### Expertise

I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world! As AllExperts closes down, just google me to find my details - I will still be around answering questions!

##### Experience

My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

Education/Credentials
I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!