I am trying to write an Excel VBA function that will return one of two input parameters as the formula for the cell it is input in based on a global setting somewhere else in the sheet. IE, somewhere else in the sheet someone sets A or B, then formulas that call the functon AorB will return A or B based on what the global setting is.
Something like this:
Function AOrB(A As Variant, B As Variant) As Variant
If someSetting = A Then
AOrB.formula = A
ElseIf someSetting = B Then
AOrB.formula = B
End If
End Function
I've scrounged pretty heavily but I just don't have the knowledge of what types to input and return in order to allow the function to return.
Any help would be appreciated.