function doesn't work

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top