+ Reply to Thread
Results 1 to 8 of 8

If Function that selects numerical value based on text value in different cell

  1. #1
    Registered User
    Join Date
    06-07-2014
    Posts
    2

    Exclamation If Function that selects numerical value based on text value in different cell

    Okay...
    I need a function that will help me to sort the following information.
    A1 A2

    CPO 4
    CVH 7
    CVL 5
    GCR 3
    OVV 8
    PFO 6
    SEA 10
    WTR 11

    So, if A1 says WTR... I need A2 to pop up with the corresponding number (11).

    I had come up with...
    =IF(A1="CPO",4)*OR(A1="CVH",7)*OR(A1="CVL",5)*OR(A1="GCR",3)*OR(A1="OVV",8)*OR(A1="PFO",6)*OR(A1="SEA",10)*OR(A1="WTR")
    But it is not calculating correctly and I am not sure WHY.... HELP!!!!!!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,909

    Re: If Function that selects numerical value based on text value in different cell

    Data Range
    A
    B
    C
    D
    E
    1
    PFO
    6
    CPO
    4
    2
    CVH
    7
    3
    CVL
    5
    4
    GCR
    3
    5
    OVV
    8
    6
    PFO
    6
    7
    SEA
    10
    8
    WTR
    11
    9
    10
    Formul in B1
    =VLOOKUP(A1,$D$1:$E$8,2,FALSE)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: If Function that selects numerical value based on text value in different cell

    one way
    =LOOKUP(a1,{"CPO","CVH","CVL","GCR","OVV","PFO","SEA","WTR"},{4,7,5,3,8,6,10,11})
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: If Function that selects numerical value based on text value in different cell

    If your data is in A2:B9, then try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  5. #5
    Registered User
    Join Date
    06-07-2014
    Posts
    2

    Re: If Function that selects numerical value based on text value in different cell

    This one worked great!! Thanks!! No how do I make it where if the corresponding cell is blank then it won't show anything? right now it is showing #ref or something when it is empty

  6. #6
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: If Function that selects numerical value based on text value in different cell

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Edit: Alternatively, you could do
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by k64; 06-07-2014 at 06:54 PM.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: If Function that selects numerical value based on text value in different cell

    =iferror(lookup(a1,{"cpo","cvh","cvl","gcr","ovv","pfo","sea","wtr"},{4,7,5,3,8,6,10,11}),"")

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: If Function that selects numerical value based on text value in different cell

    This is one way of eliminating the error caused by a blank A1:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This covers the Blank A1 and other errors:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by newdoverman; 06-07-2014 at 06:48 PM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Populating a cell based on what the user selects from a drop down
    By Chuck_N in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-07-2014, 12:54 PM
  2. Date-based VBA macro selects wrong cell.
    By Dralky in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2013, 06:38 PM
  3. help. Search based on text input in a column selects a row and copies data.
    By ridermarangoni in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2012, 10:53 AM
  4. Replies: 2
    Last Post: 07-20-2008, 09:53 PM
  5. Search function (text or numerical)
    By marciac in forum Excel General
    Replies: 4
    Last Post: 07-14-2006, 10:00 AM

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