To bridge the gap between the code sample that you had, and the answer that user3423985 gave, here is a variation (assuming that I understand what you were trying to do):
Option Compare Text
Function orders(itemnum, binnum)
' look up itemnum in either sheet OpenIBP or sheet OpenIST
' depending on the value of binnum
Dim sheetName As String
If binnum = "ibp" Then
sheetName = "OpenIBP"
Else
sheetName = "OpenIST"
End If
Dim sh As Worksheet
Set sh = ActiveWorkbook.Sheets(sheetName)
' now we can look up something in the sheet:
Dim value
' Look up the value itemnum
' in column A of sheet sh
' return the corresponding value in column 2
' return exact match only
value = Application.VLookup(itemnum, sh.[A:B], 2, False)
' check for error in lookup
If IsError(value) Then
MsgBox "Item " & itemnum & " not found!"
Else
orders = value
End If
End Function