Advertisement
Guest User

Untitled

a guest
Feb 6th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Ooieoey iienea aoaee?o?ueo yeaiaioia a n?aco 2 eieiieao. Aoaeeeaoii
  2. 'n?eoaaony niaiaaaiea cia?aiee n?aco a 2 eieiieao (ia?ana?aiea iii?anoa)
  3. 'noaiaa?oiay yenaeaaneay ooieoey COUNTIF ia ?aaioaao ni no?ieaie aieuoa 256 neiaieia (
  4. 'Ooieoe? iaaicii?ii eniieuciaaou iiaoi?ii. Ia?aienaou
  5. Public Function CountDuplicates2(rngRange1 As Range, rngRange2 As Range) As Integer
  6. Dim wsCur As Worksheet
  7.  
  8. Dim CallerRange As Range
  9.  
  10. Dim CallerCol, CallerRow As Integer
  11.  
  12. Dim rngCol1, rngCol2 As Integer
  13. Dim CheckCell1, CheckCell2 As String
  14.  
  15. Dim theCell As String   'Current test value
  16.  
  17. Dim iRow As Integer
  18.  
  19. Set CallerRange = Application.caller
  20.  
  21. CallerCol = CallerRange.Column      'Maybe none required
  22. CallerRow = CallerRange.row
  23.  
  24. rngCol1 = rngRange1.Cells(1, 1).Column
  25. rngCol2 = rngRange2.Cells(1, 1).Column
  26.  
  27. CountDuplicates2 = 1        ' API FIX
  28.  
  29. If wsCur Is Nothing Then
  30.     Set wsCur = ThisWorkbook.Application.caller.Worksheet
  31. End If
  32.  
  33. CheckCell1 = wsCur.Cells(CallerRow, rngCol1).Value
  34. CheckCell2 = wsCur.Cells(CallerRow, rngCol2).Value
  35.  
  36. If CheckCell1 = "" Then
  37.     'Return operator simulation
  38.    GoTo EndFunction
  39. End If
  40.  
  41. If CheckCell2 = "" Then
  42.     'Return operator simulation
  43.    GoTo EndFunction
  44. End If
  45.  
  46. 'FIXME: Remove hardcode. Use Model, Luke
  47. For iRow = 4 To (4 + rngRange1.Rows.Count) - 1
  48.     If iRow = CallerRow Then
  49.         'Continue operator simulation
  50.        GoTo Continue_iRow
  51.     End If
  52.  
  53.     theCell = wsCur.Cells(iRow, rngCol1).Value
  54.    
  55.     If theCell <> CheckCell1 Then
  56.         'Current Cell is not equals test value
  57.        'Continue operator simulation
  58.        GoTo Continue_iRow
  59.     End If
  60.  
  61.     theCell = wsCur.Cells(iRow, rngCol2).Value
  62.  
  63.     If theCell <> CheckCell2 Then
  64.         'Current Cell is not equals test value
  65.        'Continue operator simulation
  66.        GoTo Continue_iRow
  67.     End If
  68.  
  69.     'All checks passed
  70.  
  71.     CountDuplicates2 = CountDuplicates2 + 1
  72.  
  73. Continue_iRow:
  74. Next iRow
  75.  
  76. EndFunction:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement