Results 1 to 3 of 3

Creating a new function which can handle cell references

Threaded View

genobz Creating a new function which... 02-22-2013, 05:59 AM
OllieB Re: Creating a new function... 02-22-2013, 06:39 AM
genobz Re: Creating a new function... 02-22-2013, 07:08 AM
  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    Delhi
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Creating a new function which can handle cell references

    Hi

    i was attempting to create a new function using VBA. However i am unable to run it successfully. The most probable reason from my end is my inability to pass the cell references correctly.

    Here's the long function that i want to transform into a new function.

    =IFERROR(VLOOKUP(A1,Sheet2!$A$1:$C$5,HLOOKUP("Price",Sheet2!$A$1:$C$5,2,FALSE),FALSE),"")
    This function is actually used to lookup a value corresponding to given parameters

    Sample Table:
    Model Company Price
    1 2 3
    iPad Apple 1000
    Galaxy Samsung 2000
    Lumia Nokia 3000

    The resultant new function should be something like
    =value_find(A1,Sheet2!$A$1:$C$5,"Price")
    I have written the VBA code for the same as
    Function value_find(Test_Value, ByVal Table_Name As Range, Col_Name)
    A = Application.HLookup(Col_Name, Table_Name, 2, False)
    B = Application.VLookup(Test_Value, Table_Name, A, False)
    value_find = B
    End Function
    This code doesn't return any compile error. However, when used the only value it returns is "0"

    Pls advise on the corrections required.

    Thanks so much
    Last edited by genobz; 02-22-2013 at 06:04 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1