Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. False Negative
  2. False Negative, False Positive
  3.  
  4. False Negative
  5. False Positive
  6. Positive
  7.  
  8. False Negative 2
  9. False Positive 1
  10.  
  11. =SUMPRODUCT((LEN(Rng)-LEN(SUBSTITUTE(Rng,G1,"")))/LEN(G1))
  12.  
  13. =FindPhrase(Rng,G1)
  14.  
  15. Option Explicit
  16. Function FindPhrase(SearchRange As Range, Phrase As String) As Long
  17. Dim RE As Object, MC As Object
  18. Dim sPat As String
  19. Dim V As Variant
  20. Dim I As Long, J As Long
  21.  
  22. V = SearchRange
  23.  
  24. Set RE = CreateObject("vbscript.regexp")
  25. With RE
  26. .Global = True
  27. .MultiLine = True
  28. .ignorecase = True
  29. .Pattern = "(?:^|,s*)" & Phrase & "(?:s*,|$)"
  30. End With
  31.  
  32. For I = 1 To UBound(V, 1)
  33. If RE.test(V(I, 1)) Then J = J + 1
  34. Next I
  35.  
  36. FindPhrase = J
  37.  
  38. End Function
  39.  
  40. .Pattern = "(?:^|,s*)Positive(?=(?:s*,|$))"
  41.  
  42. Option Explicit
  43. Function FindPhrase2(SearchRange As Range, Phrase As String) As Long
  44. Dim V As Variant
  45. Dim I As Long, J As Long, K As Long
  46. Dim aStrings As Variant
  47.  
  48. V = SearchRange
  49. For I = 1 To UBound(V)
  50. aStrings = Split(V(I, 1), ",")
  51. If IsArray(aStrings) Then
  52. For J = 0 To UBound(aStrings)
  53. If Trim(aStrings(J)) = Trim(Phrase) Then K = K + 1
  54. Next J
  55. Else
  56. If Trim(aStrings) = Trim(Phrase) Then K = K + 1
  57. End If
  58. Next I
  59.  
  60. FindPhrase2 = K
  61.  
  62. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement