+ Reply to Thread
Results 1 to 9 of 9

Contract rule changing depending on date using countifs and vlookup

  1. #1
    Registered User
    Join Date
    02-25-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2007
    Posts
    24

    Contract rule changing depending on date using countifs and vlookup

    Hello all.

    I'm trying to have a formula look at a list of contracts and come back with the contract rule depending on the date of an order. For example, I have a list of several contracts (listed on a separate sheet of the workbook) but one customer has two separate contracts for one customer - one (the older contract) with effective dates of of 01/01/19 - 04/30/2019 and another (the new contract) with effective dates of 05/01/19 - 04/30/2020. Each of these contracts has a specific rule (days to charge the customer). On the old contract, the rule is to bill 3 days, the new 5 days. The rules are for several customers (Several different names).

    On the list of orders, there are different orders created that fall into these different contract rules. The order dated 04/29/2019 should come back with a rule bill 3 days. The order dated 05/03/2019 should come back with a rule bill 5 days.

    The formula I thought would easily work is =IF(COUNTIFS(Contracts!G:G, "<="&Order!C2, Contracts!H:H, ">="&Order!C2,Contracts!B:B, "*"&A2&"*"), VLOOKUP("*"&A2&"*", Contracts!B:I, 3, FALSE), "No Rule")

    You might ask the question "why the wild cards for the name look up?". The reason is the entry point is manual (by a person) and for ease of that, they are only entering the key word for the company name but the contract shows the full name... for example: Entry of Richard would bring back the rule for RICHARD NICKS AND CO.

    Please help me figure this out. Need the correct rule to come back depending on the order date. Thanks. Workbook attached.
    Attached Files Attached Files
    Last edited by rfigueroa1976; 07-24-2019 at 06:22 PM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Countifs and vlookup

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve.)

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Countifs and vlookup

    One way - Enter this as an array formula in Cell D2 on your Orders sheet and copy down...

    Please Login or Register  to view this content.
    As this is creating an array, we can't use whole column references, so dependent on the number of rows in your Contract list, you will need to update the end row references from 3 to your last row.

    Just to clarify the SEARCH function for you, I don't believe (I could be wrong) that you can use wildcards when it's just an = comparison.

  4. #4
    Registered User
    Join Date
    02-25-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2007
    Posts
    24

    Re: Countifs and vlookup

    Changed. Hopefully that helps. Really struggled to figure out what to title it.
    Last edited by rfigueroa1976; 07-24-2019 at 06:33 PM.

  5. #5
    Registered User
    Join Date
    02-25-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2007
    Posts
    24

    Re: Countifs and vlookup

    Quote Originally Posted by EchoPassenger View Post
    One way - Enter this as an array formula in Cell D2 on your Orders sheet and copy down...

    Please Login or Register  to view this content.
    As this is creating an array, we can't use whole column references, so dependent on the number of rows in your Contract list, you will need to update the end row references from 3 to your last row.

    Just to clarify the SEARCH function for you, I don't believe (I could be wrong) that you can use wildcards when it's just an = comparison.


    This partially worked for me... Can you help with the issue I'm having... The problem is when A2 is blank. The formula populates whatever it wants right now (randomly selects one of the contract rules). Is there a way to have the formula say "No Rule" if A2 is blank or, maybe come back as "#N/A"?

    INDEX(Contracts!D$2:D$3,MATCH(1,(IFERROR(SEARCH(A2,Contracts!B$2:B$3),0)*(C2>=Contracts!G$2:G$3)*(C2<=Contracts!H$2:H$3)),0))
    Last edited by rfigueroa1976; 07-26-2019 at 03:00 PM.

  6. #6
    Registered User
    Join Date
    02-25-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2007
    Posts
    24

    Re: Contract rule changing depending on date using countifs and vlookup

    Any additional help on this?

    This partially worked for me... Can you help with the issue I'm having... The problem is when A2 is blank. The formula populates whatever it wants right now (randomly selects one of the contract rules). Is there a way to have the formula say "No Rule" if A2 is blank or, maybe come back as "#N/A"?

    INDEX(Contracts!D$2:D$3,MATCH(1,(IFERROR(SEARCH(,Contracts!B$2:B$3),0)*(C2>=Contracts!G$2:G$3)*(C2<=Contracts!H$2:H$3)),0))

  7. #7
    Registered User
    Join Date
    02-25-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2007
    Posts
    24

    Re: Contract rule changing depending on date using countifs and vlookup

    Can anyone else help on this?

  8. #8
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Contract rule changing depending on date using countifs and vlookup

    Apologies for the delay in returning. You just need to add an IF function to deal with a blank value.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-25-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2007
    Posts
    24

    Re: Contract rule changing depending on date using countifs and vlookup

    Thanks for the reply. I will try that Monday.

+ 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. Replies: 6
    Last Post: 03-19-2019, 09:14 PM
  2. countifs into vlookup? Need help with a project!
    By godofelru in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-29-2016, 03:17 PM
  3. [SOLVED] Countifs and vlookup?
    By clevername1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-29-2015, 03:41 PM
  4. CountIfs - IF - or - Vlookup?
    By robbfamily in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-23-2015, 12:12 PM
  5. [SOLVED] VLOOKUP and COUNTIFS
    By tamille in forum Excel General
    Replies: 7
    Last Post: 11-25-2013, 04:15 PM
  6. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  7. Help with COUNTIFS and VLOOKUP
    By Ponce in forum Excel General
    Replies: 1
    Last Post: 05-11-2011, 02:10 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