• 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.

Improving Function UDF

bines53

Active Member
Hello friends,

I would like to help, this function does not allow me to enter into other functions, including built-in functions of Excel, should probably supplement the existing code.


Code:
Function Pair(r As Range, s As Range) As Integer
  Dim c As Range
  Dim d() As Variant
  ReDim d(1 To s.Cells.Count)
  For i = 1 To s.Cells.Count
  d(i) = s.Cells(i).Value
  Next i

  For Each c In r
  If c <> "" Then
  For i = 1 To s.Cells.Count
  If c = d(i) Then
  Pair = Pair + 1
  d(i) = ""
  GoTo NextC
  End If
  Next i
  End If
NextC:
  Next c
End Function
The function makes a comparison between two tables,

Thank you !
 
Last edited by a moderator:
Hi David ,

I don't think it needs any improvement , unless you can specify the area where you think it needs improvement.

For it to be used as a UDF , all that is required is for it to be placed in a module.

See the attached file.

Narayan
 

Attachments

  • Pair.xlsm
    13.5 KB · Views: 3
See if the attached does what you want - I can only guess.
I've used the function code from this thread for Pair with a tweak to get rid of the GoTo (which I hate).
In cells H1:H8 is a guess at wat you're looking for; I've moved some ranges onto other sheets. The formulae are not array formulae, they're normally entered formulae and copied down.
 

Attachments

  • chandoo21053and24690test 8-1.xlsm
    15.5 KB · Views: 1
Back
Top