+ Reply to Thread
Results 1 to 10 of 10

Vlookup / Countif Combination

Hybrid View

  1. #1
    Registered User
    Join Date
    03-28-2017
    Location
    Durham
    MS-Off Ver
    2010
    Posts
    38

    Vlookup / Countif Combination

    Hello, I am trying to apply a vlookup / countif combination on a simple dataset.

    I have several consecutive zones of varying lengths. Some actions have been applied on subsections within these zones therefore I want to count how much has been completed.

    For example;

    Zone 1: 50 to 65, Action 1 was completed between 60 and 70, therefore the count is 5.

    Please see attached worksheet with manually completed desired output.

    As always your help is much appreciated.

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Vlookup / Countif Combination

    Your numbers don't seem to make any sense to me. Maybe I'm missing something?

  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,948

    Re: Vlookup / Countif Combination

    I, also, am not sure what you are trying to do here
    Keep in mind that while you know exactly what you are doing, we have no clue whatsoever
    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
    03-28-2017
    Location
    Durham
    MS-Off Ver
    2010
    Posts
    38

    Re: Vlookup / Countif Combination

    Hmmm, okay;

    Say I have zones of various distance; 1-10km, 11-20km, 21-30km. This is defined in the first table.

    Then I have a second table which comprises actions within the defined zones i.e. between 3-6km (count as 4km within zone 1), 18-25km (count as 3km in zone 2 and 5km in zone 3).

    I need a lookup / countif formula within column E of my example sheet that will lookup the range and then count values for each zone for actions completed within my second table.

    Its simple, just difficult to describe. Let me know if this further explanation helps.

    Cheers

  5. #5
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Vlookup / Countif Combination

    Maybe explain how you arrive at 13 for the first highlighted value.

  6. #6
    Registered User
    Join Date
    03-28-2017
    Location
    Durham
    MS-Off Ver
    2010
    Posts
    38

    Re: Vlookup / Countif Combination

    Okay, so Section 1 ranges from 50km to 60km.

    Out of the 5 actions, Action 1 and Action 2 cover part of this zone. Action 1 running from 52km to 60km (8km) and Action 2 running from 60km to 65km (5km) So in total 13km of Section 1 is complete from Actions 1 and 2.

    Thanks

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,646

    Re: Vlookup / Countif Combination

    In E3 then drag down

    =MAX(0,MIN($I$3,$C3)-MAX($H$3,$B3))+MAX(0,MIN($I$4,$C3)-MAX($H$4,$B3))+MAX(0,MIN($I$5,$C3)-MAX($H$5,$B3))+MAX(0,MIN($I$6,$C3)-MAX($H$6,$B3))+MAX(0,MIN($I$7,$C3)-MAX($H$7,$B3))
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Vlookup / Countif Combination

    A little differently. Array entered returns same results.

    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    =SUM(IF(MMULT((ROW(INDIRECT(B3*2&":"&C3*2))>=TRANSPOSE($H$3:$H$7*2))*(ROW(INDIRECT(B3*2&":"&C3*2)) <
    TRANSPOSE($I$3:$I$7*2)),{1;1;1;1;1})/2,0.5))
    Dave

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,646

    Re: Vlookup / Countif Combination

    Here is another formula which will have fixed length irrespective of number of "Actions".
    ARRAY formula in E3 then drag down.
    =SUM(IF(($B3<$I$3:$I$7)*($C3>$H$3:$H$7),IF($C3>=$I$3:$I$7,IF($B3<=$H$3:$H$7,$I$3:$I$7-$H$3:$H$7,$I$3:$I$7-$B3),IF($B3<=$H$3:$H$7,$C3-$H$3:$H$7,$C3-$B3))))
    Attached Files Attached Files

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Vlookup / Countif Combination

    Managed to shorten the formula in my previous post #8. Still array entered.

    Formula: copy to clipboard
    =SUM(MMULT((ROW(INDIRECT(B3*2&":"&C3*2))/2>=TRANSPOSE($H$3:$H$7))*(ROW(INDIRECT(B3*2&":"&C3*2))/2 <
    TRANSPOSE($I$3:$I$7)),{1;1;1;1;1}/2))

+ 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. Countif Unique combination!!!
    By deadlyliquidxxx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-01-2015, 03:08 PM
  2. Macro code needed for combination of (If,Countif,vlookup)
    By Dharmadme in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2014, 03:58 PM
  3. countif-sumif combination??
    By dumaser88 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-20-2013, 02:37 PM
  4. Combination of CountIF, IF, and NOT
    By shani20 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2011, 06:58 PM
  5. Combination of Countif and Vlookup?
    By Janusian in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-26-2009, 04:48 AM
  6. COUNTIF/VLOOKUP/MATCH combination
    By gmcana in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2008, 04:32 PM
  7. [SOLVED] COUNTIF COMBINATION??
    By Heather in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-25-2005, 10:06 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