+ Reply to Thread
Results 1 to 10 of 10

IF, AND, OR Help

  1. #1
    Registered User
    Join Date
    12-24-2014
    Location
    albany ny
    MS-Off Ver
    2010
    Posts
    18

    IF, AND, OR Help

    Travel Template.xlsxSo this post is actually based on a previous post of mine... But now the issue has been complicated further.

    Here's what I need:
    AT costs $2.50/mile and has a $25 fee for loading wheelchairs (WC) or scooters (SCOOTER)
    CD costs $5.00/mile and has a $75 fee for loading wheelchairs or scooters
    There is no additional loading cost if the vechicle is SEDAN
    VA will cost the same as CD
    If column L says "RT" (Round Trip), I need to double the mileage I enter in column N
    If column L says "OW" (One Way), the mileage in column N remains the same -- whatever value is entered.
    There is a possibility that Columns A and C will be different carriers (either both CD, both AT, or a combination)

    Can anyone help me with this? Here is the previous formula I was using:
    =IF(AND(L7="RT",OR(M7={"WC","SCOOTER"})),150+5*N7,IF(AND(L7="OW",OR(M7={"WC","SCOOTER"})),75+5*N7,2.5*N7))

    This does not take into account that AT and CD cost different amounts for mileage.

    I attached the spreadsheet if that helps... THANK YOU!!!!
    Last edited by tenglish01; 01-28-2015 at 02:47 PM.

  2. #2
    Registered User
    Join Date
    12-24-2014
    Location
    albany ny
    MS-Off Ver
    2010
    Posts
    18

    Re: IF, AND, OR Help

    Is more information needed to help with this?

  3. #3
    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,929

    Re: IF, AND, OR Help

    Can I suggest that you add some dummy data to your workbook - even if you have to calc it and enter it manually?
    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

  4. #4
    Registered User
    Join Date
    12-24-2014
    Location
    albany ny
    MS-Off Ver
    2010
    Posts
    18

    Re: IF, AND, OR Help

    Quote Originally Posted by FDibbins View Post
    Can I suggest that you add some dummy data to your workbook - even if you have to calc it and enter it manually?
    Travel Template_00.xlsx

    Does that help? I need the "COST" Column to auto-populate with the other pertinent information.

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: IF, AND, OR Help

    in O7:
    =IF(A7="AT",2.5,5)*N7+(L7="RT")*IF(C7="AT",2.5,5)*N7+(M7<>"SEDAN")*(IF(A7="AT",25,75)+IF(C7="AT",25,75))

    Drag down.
    Last edited by Pauleyb; 01-28-2015 at 05:17 PM. Reason: solved per 'duplicate' post then noticed that the IN and OUT fields may be different per the initial post above.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: IF, AND, OR Help

    This one uses a lookup table and named ranges:
    Please Login or Register  to view this content.
    If column L = OW then CHOOSE returns 1 which causes it to calculate column A & C miles based on carriers, etc and adds, if RT then multipy Column A miles by 2...
    Attached Files Attached Files
    Last edited by protonLeah; 01-28-2015 at 06:37 PM.
    Ben Van Johnson

  7. #7
    Registered User
    Join Date
    12-24-2014
    Location
    albany ny
    MS-Off Ver
    2010
    Posts
    18

    Re: IF, AND, OR Help

    Quote Originally Posted by protonLeah View Post
    This one uses a lookup table and named ranges:
    Please Login or Register  to view this content.
    If column L = OW then CHOOSE returns 1 which causes it to calculate column A & C miles based on carriers, etc and adds, if RT then multipy Column A miles by 2...
    I've never used a lookup table before... how does this work, exactly?

  8. #8
    Registered User
    Join Date
    12-24-2014
    Location
    albany ny
    MS-Off Ver
    2010
    Posts
    18

    Re: IF, AND, OR Help

    Quote Originally Posted by Pauleyb View Post
    in O7:
    =IF(A7="AT",2.5,5)*N7+(L7="RT")*IF(C7="AT",2.5,5)*N7+(M7<>"SEDAN")*(IF(A7="AT",25,75)+IF(C7="AT",25,75))

    Drag down.
    This isn't working... With no values entered, it still gives me a value of 150.

  9. #9
    Registered User
    Join Date
    12-24-2014
    Location
    albany ny
    MS-Off Ver
    2010
    Posts
    18

    Re: IF, AND, OR Help

    Hey! It works! Perfect, thank you!

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: IF, AND, OR Help

    For instance, given:
    INDEX(RateTable, MATCH($C7,CarrierList,0), 2),

    1. The first parameter, RateTable, is the group of cells A1:E6 in the "lookup tables" tab.

    2. The second parameter, MATCH($C7,CarrierList,0), calculates the row in the table to use. Here, it is looking for the carrier code ("AT" in C7) in the carrierlist (the first column of the lookup table). "AT" is found at row 3.

    3. The third parameter, 2, specifies which column to return the value from.

    So, in this case, INDEX returns the value from row 3, column 2, i.e., $5.00.




    There are also two named ranges

    "OW " (cell N1) and "RT" (M1), &
    M1 holds value 2 and N1 holds value 1.

    So, INDIRECT($L7), will take the type of trip in cells of column L (OW in the sample file) and use that as the named range to fetch the value from. Since L7 holds OW, INDIRECT looks in cell named "OW" and returns: 1.

    Since INDIRECT will only return a 1 or 2, CHOOSE(INDIRECT($L7)..., picks from 2 formulas to calculate miles

    If it's 1 then the first formula is evaluated (IN + OUT) , if 2 then evaluate the round trip formula (2 x IN):

    CHOOSE( 1 or 2, (IN + OUT), (2 x IN))
    Last edited by protonLeah; 01-29-2015 at 03:47 PM.

+ 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