ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA Lookup Functions (https://www.excelbanter.com/excel-programming/353562-excel-vba-lookup-functions.html)

hoppermr

Excel VBA Lookup Functions
 
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.

Bob Phillips[_6_]

Excel VBA Lookup Functions
 
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)

"hoppermr" wrote in message
...
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.





All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com