+ Reply to Thread
Results 1 to 11 of 11

Change my code into Excel formula code

Hybrid View

  1. #1
    Registered User
    Join Date
    12-20-2012
    Location
    Englewood, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    5

    Change my code into Excel formula code

    I have never written an advanced formula in excel before and am looking into making a Logical:IF statement/formula but I don't know how. I took some classes in programming 10+ years ago so I can follow the logic somewhat...

    I want to write a formula that will tell me how many days it will take the warehouse to deliver to the ship-to state.

    Column A I have which Warehouse it is shipping from= "East"(NC) or "West"(CA)
    Column B is the state it is shipping to.
    Column C is blank but I want it to calculate the days it will take to ship with this formula/macro.

    Here is my try at the coding: Can someone help me put it into Excel coding?(== = equal, || = or, // = comment)

    IF(A1 == "EAST" && B1 == CA || NV || WY || OR || WA || MT || UT || ID,
    then C1 == "5 Days";
    ELSEIF(A1 == "EAST" && B1 == ND || SD || NE || CO ||AZ || NM,
    then C1 == "4 Days";
    ELSEIF(A1 == "EAST" && B1 == KS || IA || MN || WI || OK || AR || TX || MA || RI || ME || NH || VT,
    then C1 == "3 Days";
    ELSEIF(A1 == "EAST" && B1 == GA || FL || AL || MS || MO || IN || IL || MI || PA || NY || DC || NJ || CT || MD || WV || KY || OH,
    then C1 == "2 Days";
    ELSEIF(A1 == "EAST" && B1 == VA || NC || SC,
    then C1 == "1 Day";

    IF(A1 == "WEST" && B1 == RI || CT || VT || NH || NC || SC || VA,
    then C1 == "5 Days";
    ELSEIF(A1 == "WEST" && B1 == ND || SD || NE || KS || MN || WI || OH || IA || IL || MO || AR || LA || MS || AL || GA, // ETC.ETC.
    then C1 == "4 Days";
    ELSEIF(A1 == "WEST" && B1 == WA || ID || OR || MT || CO || NM || OK || TX,
    then C1 == "3 Days";
    ELSEIF(A1 == "WEST" && B1 == NV || AZ || UT,
    then C1 == "2 Days";
    ELSEIF(A1 == "WEST" && B1 == CA,
    then C1 == "1 Day";


    Now there are 5,000+ rows also, so would I just drag the formula down into the rows below it? Or is there a better way to write in the code for next row? So it says (A2 == "WEST" && B2 == CA, then C2 ==)(A3/B3, then C3) etc.etc.

    I appreciate the help, this forum always gets the best answers according to google!
    Last edited by DGARRETT1; 01-08-2013 at 03:30 PM. Reason: Title Change

  2. #2
    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
    53,048

    Re: Need help writing a formula...

    DGarret, welcome to the forum

    however, please rename your thread to something more meaningful, that actually describes your problem. lots of contributors will look at a thread title, and if it is of interest to them, or falls within their area of expertese, they might only open those threads. also, searching for "help" will not turn up too many results that will benifit you, sorry.
    To change a Title on your post, click EDIT on you're 1st post, then Go Advanced and change your title"
    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

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help writing a formula...

    "WEST" && B1 == RI || CT || VT || NH || NC || SC || VA,

    For B1 I suppose it needs to fit to one of the values (or has it to fit to all the values).

    I that case (if you only need one of the values) you can use VLookup for that.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Registered User
    Join Date
    12-20-2012
    Location
    Englewood, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need help writing a formula...

    It looks to me like VLookup is returning a value already listed in the worksheet, but in my case I need it to do a calculation of number of days it will take to deliver from A1(warehouse) to B1(state). Can you show an example of what you mean or did you think I needed the State value returned?
    I think what I really need is a case statement but I can't find anything on the web that shows how to do a case statement in Excel, only Visual Basic Select-Case which I don't have access to here. I can't use a nested IF statement either because there are more than 7 statements in my code. And too many OR statements anyways, what I've found is that I can't use ("WEST" && B1 == RI || CT || VT || NH || NC || SC || VA) It would have to be OR("WEST" && B1 == RI),OR("WEST" && B1 == CT),OR("WEST" && B1 == VT)etc...
    I will keep looking for the answer and if I ever figure it out I will post it here, but I am losing hope it seems too complicated for Excel!

  5. #5
    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
    53,048

    Re: Change my code into Excel formula code

    thanks for the title change

    perhaps this will get you headed in the right direction (syntax-wise), i assume that this is going into C1 abd being copied down?...

    IF(A1 == "EAST" && B1 == CA || NV || WY || OR || WA || MT || UT || ID,
    then C1 == "5 Days";

    =if(and(A1="east",or(B1="CA",B1="NV",B1="WY",B1="OR",B1="WA",B1="MT",B1="UT",B1="ID")),"5days",if(......

    it would be easier if you could put the CA, NV etc in a table and then reference them with ...
    ISERROR(VLOOKUP(D3,A3:A10,1,FALSE))

    =if(and(A1="east",ISERROR(VLOOKUP(D3,$A$3:$A$10,1,FALSE))),"5days",if(......

    and fyi, the restriction of 7 nested if's is no longer valid and you dont need to use double ='s and &'s

  6. #6
    Registered User
    Join Date
    12-20-2012
    Location
    Englewood, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Change my code into Excel formula code

    I appreciate your help, I re-wrote the code into excel format!

    =IF(AND(A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA")),"5 DAYS",IF(AND(A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN")),"4 DAYS",IF(AND(A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),"3 DAYS",IF(AND(A1="WEST",OR(B1="UT",B1="NV",B1="AZ",B1="CO",B1="AZ",B1="NM")),"2 DAYS",IF(AND(A1="WEST",OR(B1="CA")),"1 DAY",IF(AND(A1="EAST",OR(B1="CA",B1="NV",B1="WY",B1="OR",B1="WA",B1="MT",B1="UT",B1="ID")),"5 DAYS",IF(AND(A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),"4 DAYS",IF(AND(A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT")),"3 DAYS",IF(AND(A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH")),"2 DAYS",IF(AND(A1="EAST",OR(B1="VA",B1="NC",B1="SC")),"1 DAY")))))
    However I did get the error "The specified formula cannot be entered because it uses more levels of nesting than allowed in the current file format." with 2010 Microsoft Office Professional Plus Excel.
    But if I filter the EAST/WEST column into A-Z, I can split the formula in half for EAST/WEST and it works!

    Now I can see why using Lookup with tables would be much easier than searching through my code to make a change, I may make a separate worksheet in the future to reference from.

    Another question:
    Instead of returning the string "5 days" I would rather it return the value "Customer Request Date minus 5 days", in a date format, but if the date is prior to today I want it to return today's date, and I only want to count Business days(not count Weekends)

    Example1: C1(CustomerRequestDate)=01/08/2013 it would return 01/03/2013 (Today's date) Since 01/08/2013 is less than 5 business days away.
    Example2: C1(CRD)=02/08/2013 it would return 02/01/2013 Since it is 5 Business days earlier than 02/08/2013
    Example3: C1(CRD)=12/17/2012 it would return 01/03/2013 Since it is already past due.

    Here’s my try at the code:
    I had to change the previous code to return a value instead of a string:
    =IF(AND(A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA")),5,IF(…

    I was unable to figure out how to fit it into my regular code, so instead I made a new column E1(Ship date)
    so A1=Warehouse(West/East), B1=State, C1=CustomerRequestDate, D1=Days to ship, E1=Ship Date, F1=Real Ship Date

    =IF(NETWORKDAYS(C1-D1,C1)-1=D1,C1-D1,IF(NETWORKDAYS(C1-D1,C1)-1<D1,C1-D1-2))

    //(Comment) If the number of business days of C1(CRD) minus D1(Days it takes to ship) minus 1 day is equal to D1(Days it takes to ship), then there is no weekend and I get the result of C1(CRD) minus D1(Days it takes to ship)
    Or else, If the number of business days of C1(CRD) minus D1(Days it takes to ship) minus 1 Day is less than D1(Days it takes to ship), then there is a weekend in there so the result is the C1(CRD) minus D1(DTS) minus 2(weekend)

    (I tried another If statement in the previous code to incorporate “but if the date is prior to today I want it to return today's date” but It wasn’t working, so I made another Column:

    =IF(E1<=TODAY(),TODAY(),E1)

    If you can help me incorporate both codes into one or all three into one I would be appreciated! Thanks for the help, my boss is going to think I am a genius! Lol j/k
    Last edited by DGARRETT1; 01-08-2013 at 03:38 PM. Reason: Indenting makes it easier to read

  7. #7
    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
    53,048

    Re: Change my code into Excel formula code

    not that it really matters now, but if the file format you are using is .xls (2003) then maybe thats why it is restricting you to 7 levels. i have used more and seen far more (1 OP had over 200!!) nested ifs than that, using 2007.

    ok, on to your next question i'm trying to figure out what you want, but my brain is lagging a bit (its almost 1am lol) so could you break that down a bit for me please?

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change my code into Excel formula code

    This can be reduced to a simple single lookup.

    1) Create a WEST lookup table in column F:

    WEST
    RI CT VT NH NC SC VA
    ND SD NE KS MN WI OH IA IL MO AR LA MS AL GA
    WA ID OR MT CO NM OK TX
    NV AZ UT
    CA
    2) Add the EAST table in column G:

    EAST
    CA NV WY OR WA MT UT ID
    ND SD NE CO AZ NM
    KS IA MN WI OK AR TX MA RI ME NH VT
    GA FL AL MS MO IN IL MI PA NY DC NJ CT MD WV KY OH
    VA  NC SC
    3) Add the "results" table in column H:

    RESULTS
    5days
    4days
    3days
    2days
    1day
    4) Now put an EAST/WEST value in A1, and a STATE selection in B1

    5) The formula in C1 is now:

    =LOOKUP(2, 1/(ISNUMBER(SEARCH(B1, IF(A1="EAST", $G$2:$G$6, $F$2:$F$6)))), $H$2:$H$6)
    Attached Files Attached Files
    Last edited by JBeaucaire; 01-04-2013 at 02:19 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    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
    53,048

    Re: Change my code into Excel formula code

    lol thanks Jerry

  10. #10
    Registered User
    Join Date
    12-20-2012
    Location
    Englewood, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Change my code into Excel formula code

    I finally got it! Thanks for getting me in the right direction! (syntax-wise)
    I did run into the "8192 char limit" error so I split the code up into EAST and WEST.

    (WEST ONLY)
    =IF(AND(C1-7>TODAY(),NETWORKDAYS(C1-5,C1)=5,A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA",B1="PA",B1="WV",B1="NY",B1="ME")),C1-7,IF(AND(C1-7<=TODAY(),NETWORKDAYS(C1-5,C1)=5,A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA",B1="PA",B1="WV",B1="NY",B1="ME")),TODAY(),IF(AND(C1-7>TODAY(),NETWORKDAYS(C1-5,C1)=4,A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA",B1="PA",B1="WV",B1="NY",B1="ME")),C1-7,IF(AND(C1-7<=TODAY(),NETWORKDAYS(C1-5,C1)=4,A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA",B1="PA",B1="WV",B1="NY",B1="ME")),TODAY(),IF(AND(C1-4>TODAY(),NETWORKDAYS(C1-4,C1)=5,A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN",B1="MI",B1="MD")),C1-4,IF(AND(C1-4<=TODAY(),NETWORKDAYS(C1-4,C1)=5,A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN",B1="MI",B1="MD")),TODAY(),IF(AND(C1-6>TODAY(),NETWORKDAYS(C1-4,C1)=4,A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN",B1="MI",B1="MD")),C1-6,IF(AND(C1-6<=TODAY(),NETWORKDAYS(C1-4,C1)=4,A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN",B1="MI",B1="MD")),TODAY(),IF(AND(C1-6>TODAY(),NETWORKDAYS(C1-4,C1)=3,A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN",B1="MI",B1="MD")),C1-6,IF(AND(C1-6<=TODAY(),NETWORKDAYS(C1-4,C1)=3,A1="WEST",OR(B1="TN",B1="ND",B1="SD",B1="NE",B1="KS",B1="MN",B1="WI",B1="OH",B1="IA",B1="IL",B1="MO",B1="AR",B1="LA",B1="MS",B1="AL",B1="GA",B1="FL",B1="DC",B1="DE",B1="NJ",B1="MA",B1="KY",B1="IN",B1="MI",B1="MD")),TODAY(),IF(AND(C1-3>TODAY(),NETWORKDAYS(C1-3,C1)=4,A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),C1-3,IF(AND(C1-3<=TODAY(),NETWORKDAYS(C1-3,C1)=4,A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),TODAY(),IF(AND(C1-5>TODAY(),NETWORKDAYS(C1-3,C1)=2,A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),C1-5,IF(AND(C1-5<=TODAY(),NETWORKDAYS(C1-3,C1)=2,A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),TODAY(),IF(AND(C1-5>TODAY(),NETWORKDAYS(C1-3,C1)=3,A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),C1-5,IF(AND(C1-5<=TODAY(),NETWORKDAYS(C1-3,C1)=3,A1="WEST",OR(B1="OR",B1="WA",B1="ID",B1="MT",B1="WY",B1="CO",B1="NM",B1="OK",B1="TX",B1="AK",B1="HI")),TODAY(),IF(AND(C1-2>TODAY(),NETWORKDAYS(C1-2,C1)=3,A1="WEST",OR(B1="UT",B1="NV",B1="AZ")),C1-2,IF(AND(C1-2<=TODAY(),NETWORKDAYS(C1-2,C1)=3,A1="WEST",OR(B1="UT",B1="NV",B1="AZ")),TODAY(),IF(AND(C1-4>TODAY(),NETWORKDAYS(C1-2,C1)=2,A1="WEST",OR(B1="UT",B1="NV",B1="AZ")),C1-4,IF(AND(C1-4<=TODAY(),NETWORKDAYS(C1-2,C1)=2,A1="WEST",OR(B1="UT",B1="NV",B1="AZ")),TODAY(),IF(AND(C1-4>TODAY(),NETWORKDAYS(C1-2,C1)=1,A1="WEST",OR(B1="UT",B1="NV",B1="AZ")),C1-4,IF(AND(C1-4<=TODAY(),NETWORKDAYS(C1-2,C1)=1,A1="WEST",OR(B1="UT",B1="NV",B1="AZ")),TODAY(),IF(AND(C1-1>TODAY(),NETWORKDAYS(C1-1,C1)=2,A1="WEST",OR(B1="CA")),C1-1,IF(AND(C1-1<=TODAY(),NETWORKDAYS(C1-1,C1)=2,A1="WEST",OR(B1="CA")),TODAY(),IF(AND(C1-1>TODAY(),NETWORKDAYS(C1-1,C1)=1,A1="WEST",OR(B1="CA")),C1-3,IF(AND(C1-1<=TODAY(),NETWORKDAYS(C1-1,C1)=1,A1="WEST",OR(B1="CA")),TODAY()))))))))))))))))))))))))))
    (EAST ONLY)
    =IF(AND(C1-7>TODAY(),NETWORKDAYS(C1-5,C1)=5,A1="EAST",OR(B1="CA",B1="NV",B1="WY",B1="OR",B1="WA",B1="MT",B1="UT",B1="ID",B1="HI")),C1-7,IF(AND(C1-7<=TODAY(),NETWORKDAYS(C1-5,C1)=5,A1="EAST",OR(B1="CA",B1="NV",B1="WY",B1="OR",B1="WA",B1="MT",B1="UT",B1="ID",B1="HI")),TODAY(),IF(AND(C1-7>TODAY(),NETWORKDAYS(C1-5,C1)=4,A1="EAST",OR(B1="CA",B1="NV",B1="WY",B1="OR",B1="WA",B1="MT",B1="UT",B1="ID",B1="HI")),C1-7,IF(AND(C1-7<=TODAY(),NETWORKDAYS(C1-5,C1)=4,A1="EAST",OR(B1="CA",B1="NV",B1="WY",B1="OR",B1="WA",B1="MT",B1="UT",B1="ID",B1="HI")),TODAY(),IF(AND(C1-4>TODAY(),NETWORKDAYS(C1-4,C1)=5,A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),C1-4,IF(AND(C1-4<=TODAY(),NETWORKDAYS(C1-4,C1)=5,A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),TODAY(),IF(AND(C1-6>TODAY(),NETWORKDAYS(C1-4,C1)=4,A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),C1-6,IF(AND(C1-6<=TODAY(),NETWORKDAYS(C1-4,C1)=4,A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),TODAY(),IF(AND(C1-6>TODAY(),NETWORKDAYS(C1-4,C1)=3,A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),C1-6,IF(AND(C1-6<=TODAY(),NETWORKDAYS(C1-4,C1)=3,A1="EAST",OR(B1="ND",B1="SD",B1="NE",B1="CO",B1="AZ",B1="NM")),TODAY(),IF(AND(C1-3>TODAY(),NETWORKDAYS(C1-3,C1)=4,A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT",B1="AK")),C1-3,IF(AND(C1-3<=TODAY(),NETWORKDAYS(C1-3,C1)=4,A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT",B1="AK")),TODAY(),IF(AND(C1-5>TODAY(),NETWORKDAYS(C1-3,C1)=2,A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT",B1="AK")),C1-5,IF(AND(C1-5<=TODAY(),NETWORKDAYS(C1-3,C1)=2,A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT",B1="AK")),TODAY(),IF(AND(C1-5>TODAY(),NETWORKDAYS(C1-3,C1)=3,A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT",B1="AK")),C1-5,IF(AND(C1-5<=TODAY(),NETWORKDAYS(C1-3,C1)=3,A1="EAST",OR(B1="KS",B1="IA",B1="MN",B1="WI",B1="OK",B1="AR",B1="TX",B1="MA",B1="RI",B1="ME",B1="NH",B1="VT",B1="AK")),TODAY(),IF(AND(C1-2>TODAY(),NETWORKDAYS(C1-2,C1)=3,A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH",B1="LA",B1="TN",B1="DE")),C1-2,IF(AND(C1-2<=TODAY(),NETWORKDAYS(C1-2,C1)=3,A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH",B1="LA",B1="TN",B1="DE")),TODAY(),IF(AND(C1-4>TODAY(),NETWORKDAYS(C1-2,C1)=2,A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH",B1="LA",B1="TN",B1="DE")),C1-4,IF(AND(C1-4<=TODAY(),NETWORKDAYS(C1-2,C1)=2,A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH",B1="LA",B1="TN",B1="DE")),TODAY(),IF(AND(C1-4>TODAY(),NETWORKDAYS(C1-2,C1)=1,A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH",B1="LA",B1="TN",B1="DE")),C1-4,IF(AND(C1-4<=TODAY(),NETWORKDAYS(C1-2,C1)=1,A1="EAST",OR(B1="GA",B1="FL",B1="AL",B1="MS",B1="MO",B1="IN",B1="IL",B1="MI",B1="PA",B1="NY",B1="DC",B1="NJ",B1="CT",B1="MD",B1="WV",B1="KY",B1="OH",B1="LA",B1="TN",B1="DE")),TODAY(),IF(AND(C1-1>TODAY(),NETWORKDAYS(C1-1,C1)=2,A1="EAST",OR(B1="VA",B1="NC",B1="SC")),C1-1,IF(AND(C1-1<=TODAY(),NETWORKDAYS(C1-1,C1)=2,A1="EAST",OR(B1="VA",B1="NC",B1="SC")),TODAY(),IF(AND(C1-3>TODAY(),NETWORKDAYS(C1-1,C1)=1,A1="EAST",OR(B1="VA",B1="NC",B1="SC")),C1-3,IF(AND(C1-3<=TODAY(),NETWORKDAYS(C1-1,C1)=1,A1="EAST",OR(B1="VA",B1="NC",B1="SC")),TODAY()))))))))))))))))))))))))))
    Last edited by DGARRETT1; 01-08-2013 at 03:37 PM.

  11. #11
    Registered User
    Join Date
    12-20-2012
    Location
    Englewood, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Change my code into Excel formula code

    Jerry: That's really cool that you took the time to do that, however I think I'm just going to stick with one formula, it would be easier/faster for me to just create one column in the spreadsheet and paste one formula into it. No matter how ugly it looks, as long as it does what I need. lol.

    FDibbins: You're right, the spreadsheet I get is in 2003 format. I pasted it into a new book and tested my original code again and it worked this time!

    Breaking it down a bit for new question:

    Instead of returning the string "5 days/4 days/3 days/2 days/1 day" I would rather have it return a date value of when to ship.

    This date value of when to ship does not include weekends, so if it takes 5 days to ship and 2 of those days are during the weekend then it would actually take 7 days to ship(or 5 business days).
    Like if they wanted the item to ship Monday and it takes 1 day to ship, we would ship it from the warehouse on Friday not Sunday.

    I was able to do it on my own using 3 new columns but I would rather it be done in just 1 column, in the big original code.

    Here’s my 2nd try at the logic with a new perspective: 
    (CRD=Customer Request Date)

    =IF(AND(NETWORKDAYS(C1,C1-5)<5,IF(AND(C1-7<TODAY(),TODAY(),C1-7))))
    //if network days(crd,crd – 5 Days) is less than 5
    and customer request date minus 7 is less than today's date, then use todays date,
    otherwise use crd minus 7

    =IF(AND(NETWORKDAYS(C1,C1-5)=5,IF(AND(C1-5<TODAY(),TODAY(),C1-5))))
    //if network days(crd,crd - 5 days) is equal to 5
    and customer request date minus 5 is less than today's date, then use today's date, otherwise use crd minus 5

    So instead of old code:
    =IF(AND(A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA")),"5 DAYS",IF(AND…

    It would be something like:
    =IF(AND(A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA") NETWORKDAYS(C1,C1-5)<5,IF(AND(C1-7<TODAY(),TODAY(),C1-7,IF(AND(A1="WEST",OR(B1="RI",B1="CT",B1="VT",B1="NH",B1="NC",B1="SC",B1="VA") NETWORKDAYS(C1,C1-5)=5,IF(AND(C1-5<TODAY(),TODAY(),C1-5,IF(AND…

+ 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