Originally Posted by
sg2209
Hope You are doing good
I always try to do good when I can, although I wouldn't quite put myself in the category of do-gooders. In fact I can be downright wicked at times.
I am, however, quite well.
Originally Posted by
sg2209
to create formula to excel udf ( User Defined Function) that i can use it easily however i am not sure how to prepare it.
It would be good if you could supply a workbook to give us a better idea of how you're going to use it.
Depending on your version of Excel this UDF might do it for you:
Function WhatRules1(rng1, rng2)
WhatRules1 = Evaluate("IF(COUNTIF(" & rng1.Address(external:=True) & ",""Yes""),""Rule "" & TEXTJOIN("","",TRUE,FILTER({1,2,3,4}," & rng2.Address(external:=True) & "=""Yes"",""none"")),"""")")
End Function
and you'd use it like this:
2021-02-01_095102.png
If your version of Excel is older, then the above won't work, but this one might:
Function WhatRules2(rng1, rng2)
If Evaluate("COUNTIF(" & rng1.Address(external:=True) & ",""Yes"")") Then
Count = 0
For Each cll In rng2.Cells
Count = Count + 1
If cll.Value = "Yes" Then wr2 = wr2 & Count & ","
Next cll
If Len(wr2) > 0 Then wr2 = "Rules " & Left(wr2, Len(wr2) - 1) Else wr2 = "No rules"
WhatRules2 = wr2
Else
WhatRules2 = "Not Applicable"
End If
End Function
used in exactly the same way as the first UDF (except it's called WhatRules2.
Both of these UDFs assume a sequence 1,2,3,4, which you may not want. This is why it's better to provide a workbook and a bit more explanation of how you want it to work.
Originally Posted by
sg2209
Also is it possible to select the ranges though input box
All UDFs when used on a worksheet will allow you to select ranges with the mouse or type the references in.