I'm trying to create a UDF / custom function that takes the place of four vlookups to return a boolean response. It seems to work fine when I'm debugging it (I have a separate sub which calls the function so I can step through it), but when I attempt to use it, it does appear in the autocomplete box, but I always get the #REF error. I know this is meant to mean to mean that one of the references isn't there, but I really can't see what's wrong.
I've checked and double checked the values for the table array it's referencing so I know those values are correct. If someone could take a look at point out where I've gone wrong it would be greatly appreciated!
Public Function CYP102(CellRef As Range) As Boolean
Dim C102 As String
C102 = Application.WorksheetFunction.VLookup(CellRef, Sheets("Perms").Range("A2:I3001"), 7, 0)
If C102 = "16" Or C102 = "28" Or C102 = "33" Or C102 = "44" Then
CYP102 = True
Else
CYP102 = False
End If
End Function
I've checked and double checked the values for the table array it's referencing so I know those values are correct. If someone could take a look at point out where I've gone wrong it would be greatly appreciated!
Public Function CYP102(CellRef As Range) As Boolean
Dim C102 As String
C102 = Application.WorksheetFunction.VLookup(CellRef, Sheets("Perms").Range("A2:I3001"), 7, 0)
If C102 = "16" Or C102 = "28" Or C102 = "33" Or C102 = "44" Then
CYP102 = True
Else
CYP102 = False
End If
End Function