+ Reply to Thread
Results 1 to 5 of 5

Pick a name from a list for use in a formula

Hybrid View

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    Penang, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Pick a name from a list for use in a formula

    Hi,

    Could someone help with this.

    I have a formula that needs to produce a result based on the selection of a forex instrument from a list.

    e.g. I am using GBPEUR AUDUSD, AUDTWO as the names for the instruments.

    each of these has a scaling factor such as 10000, 100 or 10

    I have set up a drop down list to choose the instrument. Now I want to refer to the selected instrument as a value that can be used in the formula.

    GBPEUR is a name that has a value of 10000
    AUDUSD is a name that has a value of 100
    AUDTWO is a name that has a value of 10

    the formula would be:

    =IF(F53="Long",sum(J53-I53),sum(I53-J53))*(GBPEUR)
    or
    =IF(F53="Long",sum(J53-I53),sum(I53-J53))*(AUDUSD)
    or
    =IF(F53="Long",sum(J53-I53),sum(I53-J53))*(AUDTWO)

    when I try it the selection evaluates as text and not as a name.

    Any help would be much appreciated.

    Bob

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Pick a name from a list for use in a formula

    One way...

    Create this 2 column table:

    GBPEUR........10000
    AUDUSD.......100
    AUDTWO......10

    Assume that table is in the range G2:H4.

    A1 = drop down list

    Then:

    =IF(F53="Long",J53-I53,I53-J53)*VLOOKUP(A1,G2:H4,2,0)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Pick a name from a list for use in a formula

    Another option that doesn't require the lookup table and is suitable for short lists

    =IF(F53="Long",J53-I53,I53-J53)*LOOKUP(A1,{"AUDTWO","AUDUSD","GBPEUR"},{10,100,1000})
    Last edited by Palmetto; 07-03-2013 at 10:46 PM. Reason: CORRECT TYPO IN FORMULA
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Registered User
    Join Date
    07-01-2013
    Location
    Penang, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Pick a name from a list for use in a formula

    Many thanks for the excellent advice,

    Tony Valko's solution was perfect and also taught me about VLOOKUP.

    Bob

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Pick a name from a list for use in a formula

    Good deal. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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