Advertisement
spys1

Untitled

Nov 3rd, 2018 (edited)
62,247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.00 KB | None | 0 0
  1. Function iftrue(Fx, condition, show)
  2. iftrue = Application.WorksheetFunction.if(Fx & condition, show, Fx)
  3. End Function
  4.  
  5. Function testsum(a, b)
  6. test = Application.WorksheetFunction.Sum(a, b)
  7. End Function
  8.  
  9. Function testif(a, b, c)
  10. testif = Application.WorksheetFunction.if(a, b, c)
  11. End Function
  12.  
  13. =Application.WorksheetFunction.Sum(Range("A1"),Range("A2")) = Range("A3").Value
  14.  
  15. Function IFTrue(fx, condition As String, show)
  16. Dim tst As Boolean
  17. Dim z As Integer
  18. Dim t As String
  19. 'test whether the condition is assuming "="
  20. If InStr("<>=", Left(condition, 1)) = 0 Then condition = "=" & condition
  21. 'Find whether there is one or two qulifiers
  22. If InStr("<>=", Mid(condition, 2, 1)) > 0 Then z = 2 Else z = 1
  23. 'Parse string to remove qulifiers from the quotes and make everything a string
  24. t = """" & fx & """" & Left(condition, z) & """" & Mid(condition, z + 1) & """"
  25. 'evaluate the formula string to resolve to True or False
  26. tst = Application.Caller.Parent.Evaluate(t)
  27.  
  28. If tst Then
  29. IFTrue = show
  30. Else
  31. IFTrue = fx
  32. End If
  33. End Function
  34.  
  35. =IFtrue(SUM(A1,A2),"=A3","Must Be True")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement