Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function IFs(ParamArray Conditions() As Variant) As Variant
- 'This function is available in Excel 2016
- '=ifs(F17<>F17,"First True",12>1,"Second True",1>2,"Third True","None True!")
- 'will return "Second True"
- '=ifs(F17<>F17,"First True",12<1,"Second True",1>2,"Third True","None True!")
- 'will return "None True!"
- '=ifs(F17<>F17,"First True",12<1,"Second True",1>2,"Third True")
- 'will return False
- For i = 0 To UBound(Conditions)
- If i Mod 2 = 0 Then
- If i = UBound(Conditions) Then
- IFs = Conditions(i)
- Exit Function
- On Error GoTo BadRow
- ElseIf Conditions(i) = True Then
- IFs = Conditions(i + 1)
- Exit Function
- ElseIf Conditions(i) <> False Then
- GoTo BadRow
- End If
- On Error GoTo 0
- End If
- Next i
- If IsEmpty(IFs) Then IFs = False
- Exit Function
- BadRow:
- IFs = "#Non True/False Result in Condition " & i + 1 & ": """ & Conditions(i) & """"
- End Function
Add Comment
Please, Sign In to add comment