I'm trying to create a UDF which takes the value of a referenced cell, tests that value against a range, and depending on whether it fits within the range, will result in an "X" or an "O". Here's the only way I can get it to work:
Code:
Public Function ASE(cellRef As Variant)
Dim setpointU As Integer, setpointL As Integer
Dim enabled As String, disabled As String
cellValue = Range(cellRef).Value
setpointL = 50
setpointU = 100
enabled = "O"
disabled = "X"
If cellValue >= setpointL Or cellValue <= setpontU Then
ASE = enabled
Else
ASE = disabled
End If
End Function
Function in the Formula Bar: =AsE("D7") //(it automatically makes the s lowercase, for some reason)
Result: X
Other info that may be useful: the value of D7 is 24, which is coming from the cell's function, =VALUE(Imported!B5)
To elaborate, the ONLY WAY I can get it to technically work is when two conditions are met: 1) when I use quotation marks in the function around the referenced cell, and 2) when the parameter cellRef is Variant. If I do not use quotation marks [=ASE(D7) instead of =ASE("D7")], it does not work. If I change cellRef's data type to Range or String, it does not work. It will only return the #VALUE! error.
How am I supposed to format this so that I do not have to use quotations around the referenced cell?