function doesn't work

  • Thread starter Thread starter Claude
  • Start date Start date
C

Claude

Hi! Can anyone spot what is wrong with the following
function. I'm trying to write a function similar to
vlookup, but which allows for more flexibility. I could
swear it was working to a degree with excelXP ("find" only
picked up one element - I thought the output would be a
set of elements), but now with excel97 it doesn't work at
all.

Function lookupvalue(valuetolookup, lookuprange,
rowoffset, columnoffset)
Set rangeofvalues = lookuprange.Find(valuetolookup)
For Each element In rangeofvalues
MsgBox (element.Address)
Next element
'Set nextvalue = lookuprange.FindNext
'If nextvalue Is Nothing Then
lookupvalue = lookuprange.Find(valuetolookup).Offset
(rowoffset, columnoffset).Value
'Else: MsgBox ("multiple output")
'End If
End Function
 
Back
Top