I'm thinking of creating a VBA function similar to IFS formula wherein you could pass indefinite number of arguments but the second argument is always required.
=IFS(logical_test1, value_if_true1, [logical_test2, value_if_true2], ...)
The requirement is to compare certain values and if all are the same then output True, otherwise False.
Let's say we have this table.
Item ID | Price | Description
1001 | 10.00 | Item A
1002 | 10.00 | Item A
1003 | 25.00 | Item A
1004 | 10.00 | Item B
And if I need to do something on certain items, I would simply call the function like this:
Function(criteria1, value1, criteria2, value2, ...)
' Mark items with Price = 10.00 and Description = Item A
Dim IsAdd As Boolean: IsAdd = FnCheckData(strCriteria2, "10.00", strCriteria3, "Item A")
' Mark items with Item ID = 1002
Dim IsAdd As Boolean: IsAdd = FnCheckData(strCriteria1, "1002")
' Mark items with Item ID = 1003, Price = 25.00 and Description = Item A
Dim IsAdd As Boolean: IsAdd = FnCheckData(strCriteria1, "1003", strCriteria2, "25.00", strCriteria3, "Item A")
' This would error out since the second argument is not supplied
Dim IsAdd As Boolean: IsAdd = FnCheckData(strCriteria1)
Is this possible? If so, how? Thanks in advance!