Excel VBA Lookup Functions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a function using VBA (below) which assigns a vlookup value in
the calling cell. Code is below.

Function CreateHierachy(AccountParentID As String) As Variant
CreateHierachy = "=vlookup(" & AccountParentID & ",
$A$2:$G$65536,7,False)"
End Function

Above code has been simplified.

The function retrieves the string "=vlookup(1, $A$2:$G$65536,7,False)"
excluding the quotes. I want the cell to read the vlookup value as a formula
(not a string).

How can I do this within the function?

Thanks dudes.
 
Do you mean

Function CreateHierachy(AccountParentID As String) As Variant
CreateHierachy = Evaluate("=vlookup(" & AccountParentID & _
", $A$2:$G$65536,7,False)")
End Function

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

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

Back
Top