SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Technology Stocks : A.I. Chats

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Don Green who wrote (5)2/16/2024 10:58:21 AM
From: Don Green  Read Replies (1) of 39
 
In Excel I have multiple columns with 5 numbers in each column and I want to see how often any 2 or more numbers show up in other columns can you give me a formula to do this

There are a few ways to achieve this in Excel, depending on your specific needs and version of Excel. Here are three options:

1. Using SUMPRODUCT and SUMIFS (Excel 2016 and later):

This method combines the SUMPRODUCT and SUMIFS functions to identify and count pairs of matching numbers across your columns.

  • Formula: =SUMPRODUCT((COUNTIFS(Range1:RangeN, A2, Range1:RangeN, B2))*(COUNTIFS(Range1:RangeN, A2, Range1:RangeN, B2) > 1))
  • Explanation:
    • Range1:RangeN: Replace this with the actual range of your columns (e.g., A1:E1, B1:F1).
    • A2, B2: Replace these with the first two cells you want to check for duplicates.
    • The formula uses COUNTIFS to count the number of times each number appears across all columns, then SUMPRODUCT multiplies these counts together and filters for only cases where both numbers appeared more than once (meaning they both appeared together).
  • Repeat the formula: Drag the formula down to check more pairs of cells.
2. Using SUM and SUMPRODUCT (any Excel version):

This method uses nested SUM and SUMPRODUCT functions to achieve a similar result.

  • Formula: =SUM(SUMPRODUCT((Range1:RangeN=A2)*(Range1:RangeN=B2)*(Range1:RangeN<>"")))
  • Explanation:
    • Similar to the previous method, replace Range1:RangeN with your actual range and A2, B2 with the cells you want to check.
    • The formula checks each cell in Range1:RangeN for matches to both A2 and B2, filtering out empty cells.
  • Repeat the formula: Drag the formula down to check more pairs of cells.
3. Using VBA Macro (more advanced):

This option offers more flexibility but requires writing a macro script. This can be helpful if you have a large dataset or want more control over the counting process.

Here are some resources to help you with VBA:

Note:

  • These formulas count all pairs of matching numbers that occur in any two columns, regardless of order. If you only want to count unique pairs, you can modify the formulas to include additional conditions.
  • These formulas assume your data doesn't have blank cells or headers. Adjust accordingly if needed.
  • Remember to adjust the cell references and ranges to match your specific data layout.
I hope this helps! Let me know if you have any further questions.
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext