+ Reply to Thread
Results 1 to 10 of 10

distinguishing between 3 values and returning another value based on cell values/column

  1. #1
    Registered User
    Join Date
    09-06-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10

    distinguishing between 3 values and returning another value based on cell values/column

    Hi There

    This is what I am trying to do...just not sure if there is an easier way.
    I have a column range B5:B12
    I want to look to see if a cell in the column containes an 8, 12 or another number.
    If the cell contains a 8... I want to subtract 0.5 returning a value of 7.5
    if the cell contains a 12...I want to subtract 0.75 returning a value of 11.25
    if the cell contains another number...say a 4...just return that value.

    I was using a nested if but it was really long and did not account for the other numbers.

    Can anyone help with this.

    Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    Hi,

    Assuming you want to test each cell in B5:B12 and return a result for each cell in say C5:C12 then one way would be - in C5 copied down

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

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-06-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    Hi Richard

    I do not need to look at each cell just the column B5:b12 as only one cell will contain a value...usually an 8 or a 12 but the odd time a 4 or 5. I would like to then return the value entered in rangeB5:B12 in cell B13.
    Last edited by WTODD; 09-07-2014 at 10:17 AM.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    Maybe try using COUNTIF()?

    =IF(countif($B$5:$B$12,8)>0,.75,if(countif($B$5:$B$12,12)>0,11.25,b5))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    09-06-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    Hi Ford

    This seems to work...for the 8 and 12 but does not return a value from the column B5:B12 fi it is not an 8 or 12. Is there something that I could nest in at the end of the formula that would just have it return the value in the range B5:B12 if it is not an 8 or a 12

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    You have a range of 8 cells, which 1 of those would you want?

  7. #7
    Registered User
    Join Date
    09-06-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    I need it to look in the range. the range represents departments that an individual works in but they can only work in one department each day...hence the 8 or 12, but sometimes there are special circumstances like education or a part shift entered. I need the range checked and if it is an 8 to return 7.5 hours, if it is a 12 return 11.25 hours and if it is another number(ie..4 or 5) then just return that value.

    Does this help?

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    Yes I understand that part

    However, you are looking in a range of 8 numbers and testing to see if any of them contain your criteria - if they do, return 1 of 2 values. So lets say your data looks like this - there is no 8 or 12, which value do you want?

    B
    5
    1
    6
    2
    7
    3
    8
    4
    9
    5
    10
    6
    11
    7
    12
    9

  9. #9
    Registered User
    Join Date
    09-06-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    Hi Ford

    Sorry I guess I am not explaining this right...or I don't understand. I have a 14 day pay period that runs across the top and a list of departments down the side. For each day, I plot an 8 or a 12 in the corresponding department that the individual worked in


    There is only one entry per day but the department is what changes.I have it returning the correct hours for these two values(8 &12) but if I put a 4 in the department that the individual works I want it to just return the 4. I just want to look in the day and determine which department was worked in
    Last edited by WTODD; 09-07-2014 at 02:19 PM.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    The joys of text communication lol

    Perhaps it would be better if you uploaded a small sample workbook, showing what you have and what you want?

  11. #11
    Registered User
    Join Date
    07-21-2012
    Location
    UK
    MS-Off Ver
    Excel 365 for Enterprise - Windows PC
    Posts
    12

    Re: distinguishing between 3 values and returning another value based on cell values/colum

    I myself would use another's column (which I could hide) and put the formula that Richard posted in post 2, then calculate the sum of that column in B13.

    For example: if you posted 8 in B1, it would add 7.5 to c1 and repeat down for each line in the list, giving you the correct value in column C for each line.
    Then in B13 =sum(C1:C12)

+ 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. Returning a value from a column based on the values from 2 others
    By jessmerritt in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-08-2014, 12:17 AM
  2. [SOLVED] Returning cell values in a comment based on values in another workbook
    By Barking_Mad in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-10-2014, 04:13 AM
  3. [SOLVED] Returning all the values in a column based on the column header
    By Benisato in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2012, 11:19 AM
  4. Replies: 0
    Last Post: 09-28-2012, 07:55 AM
  5. Replies: 0
    Last Post: 03-22-2012, 03:08 PM

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