View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Lookup function in VBA

I'd use something like:

Option Explicit
Sub testme()
Dim Arr1 As Variant
Dim Arr2 As Variant
Dim res As Variant

Arr1 = Array(2, 4, 6, 8)
Arr2 = Array("a", "v", "x", "z")

res = Application.Lookup(4, Arr1, Arr2)

If IsError(res) Then
MsgBox "error"
Else
MsgBox res
End If

End Sub

(I figured you could add the real stuff (where it goes and what should be
matched).)



Fred Smith wrote:

I want to call Lookup from a macro. In Excel, the function is:

=lookup(k12,{2,4,6,8;"A","V","X","Z"})

How do I do this in VBA, as in:

cell.offset(0,16) = application.lookup(cell.offset(0,12), < what goes here? )

--
Regards,
Fred


--

Dave Peterson