View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Claude Claude is offline
external usenet poster
 
Posts: 36
Default function doesn't work

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