• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Convert array formula to UDF

YasserKhalil

Well-Known Member
Hello everyone
I have this array formula
Code:
=SUM(IF(($B$3:$B$17=B3)*(E3<$E$3:$E$17),1/COUNTIFS($B$3:$B$17,B3,$E$3:$E$17,$E$3:$E$17)))+1
And I would like to convert that formula to UDF (user-defined function)

Can you help me please?
 

Attachments

  • Sample.xlsm
    10.2 KB · Views: 5
Thank you very much for reply
It is just for academic curiosity and I never mind converting to VBA code .. if the UDF will be more prone to error
 
Thanks a lot Mr. Marc
How can add the letter "R" to the duplicates in results skipping the first instance
 
I tried that code but not correct results
Code:
Sub Test()
    '=SUM(IF(($B$3:$B$17=B3)*(E3<$E$3:$E$17),1/COUNTIFS($B$3:$B$17,B3,$E$3:$E$17,$E$3:$E$17)))+1
    With Range("H3:H" & Cells(Rows.Count, 2).End(xlUp).Row)
        .FormulaArray = "=SUM(IF(($B$3:$B$17=B3)*(E3<$E$3:$E$17),1/COUNTIFS($B$3:$B$17,B3,$E$3:$E$17,$E$3:$E$17)))+1"
    End With
End Sub
Also tried Evaluate and the same incorrect results
 
Hi ,

Try this :
Code:
Sub Test()
    '=SUM(IF(($B$3:$B$17=B3)*(E3<$E$3:$E$17),1/COUNTIFS($B$3:$B$17,B3,$E$3:$E$17,$E$3:$E$17)))+1
    [H3].FormulaArray = "=SUM(IF(($B$3:$B$17=B3)*(E3<$E$3:$E$17),1/COUNTIFS($B$3:$B$17,B3,$E$3:$E$17,$E$3:$E$17)))+1  & IF(COUNTIFS(B$3:B3,B3,E$3:E3,E3) = 1, """", ""R"")"
    Range("H3:H" & Cells(Rows.Count, 2).End(xlUp).Row).FillDown
End Sub
Narayan
 
Back
Top