I have a list. I want to see if it appears in one of the other sheets and return a string dependent on the sheet it is in.
E.g pseudocode:
value = "Hi"
If value in sheet 2 Then
return "Yes"
If value in sheet 3 Then
return "TDB"
Else
return " "
The code I have so far
Public Function Check(product As String) As String
Dim BLRange As Range
Dim xlCell As Range
Dim BL As Worksheet
Dim TBDRange As Range
Dim TBD As Worksheet
Dim result As String
Set BL = ActiveWorkbook.Worksheets("Sheet2")
Set BLRange = BL.Range("A1:A1000")
Set TBD = ActiveWorkbook.Worksheets("Sheet3")
Set TBDRange = TBD.Range("A1:A1000")
For Each xlCell In BLRange
If xlCell.Value = product Then
Check = "Yes"
End If
Next xlCell
For Each xlCell In TBDRange
If xlCell.Value = product Then
Check = "TBD"
End If
Next xlCell
Check = ""
End Function
When I call Check("Hi") I get #VALUE!