adjusting a formula

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
510
Office Version
  1. 365
Platform
  1. Windows
hi,
this formula checks how many repeats numbers there is in compared to previous line
but when one of the numbers repeats in both lines it count it as one,
how to fix it?
the desirable result in this example is 3 instead of 2

22
ABCDE
114612
215140
44
Cell Formulas
RangeFormula
E1:E2E1=SUM(IF(FREQUENCY(IFERROR(MATCH(A1:D1,A2:D2,0),""),COLUMN(A1:D1)-COLUMN(A1)+1)>0,1))
Press CTRL+SHIFT+ENTER to enter array formulas.


p.s
i would glad to get help with this thread too
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about:

Libro1
ABCDE
114613
215141
323460
Hoja2
Cell Formulas
RangeFormula
E1:E3E1=SUMPRODUCT(ISNUMBER(MATCH(A1:D1,A2:D2,0))+0)
 
Upvote 0
Hi,

If I understand correctly, this might work also:

Book3.xlsx
ABCDE
114613
215141
323460
Sheet3
Cell Formulas
RangeFormula
E1:E3E1=SUMPRODUCT(--(COUNTIF(A2:D2,A1:D1)>0))
 
Upvote 0
both your solutions are good, but when i checked new problem aroused,
what if in previous line there's 3-1-8-7 and in the new/above it there's 2-3-3-5
since there's only one 3 (3-1-8-7) i need the formula to count in the new line number 3 only once (2-3-3-5)
so the result will be 1
is it possible?

22
ABCDEF
114613
215141
323462
423352should be 1
531870
44
Cell Formulas
RangeFormula
E1:E5E1=SUMPRODUCT(ISNUMBER(MATCH(A1:D1,A2:D2,0))+0)
 
Upvote 0
Maybe a UDF will help you:

VBA Code:
Function CountUnique(r1 As Range, r2 As Range)
  Dim i As Long, j As Long
  Dim a As Variant, b As Variant
  a = r1.Value
  b = r2.Value
 
  For i = 1 To UBound(a, 2)
    For j = 1 To UBound(b, 2)
      If b(1, j) = a(1, i) Then
        CountUnique = CountUnique + 1
        b(1, j) = "x"
        Exit For
      End If
    Next
  Next
End Function

HOW TO INSTALL UDFs
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use CountUnique just like it was a built-in Excel function. For example:

varios 08mar2022.xlsm
ABCDE
114613
215141
323462
423351
531871
611114
711110
Hoja3
Cell Formulas
RangeFormula
E1:E7E1=CountUnique(A1:D1,A2:D2)
 
Upvote 0
Solution
DanteAmor
thank you !

is there a way to permanently keep this udf in excel ? not just in one file
 
Upvote 0
is there a way to permanently keep this udf in excel ? not just in one file

Check the following link:
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top