+ Reply to Thread
Results 1 to 7 of 7

How do i combine a vlookup function with a countif function?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-25-2016
    Location
    Helston Cornwall
    MS-Off Ver
    MS 2013
    Posts
    4

    Post How do i combine a vlookup function with a countif function?

    Hello all,

    I'm doing a weekly work roster that is spread over 3 separate sheets in the same workbook. Here is a brief synopsis of the layout of my work book, so that you may understand what I am trying to achieve and hopefully be able to assist me.

    My first sheet is an Orbat sheet that has peoples names radio callsign and their grade. In total there are 7 columns and 26 rows, not including headers.

    The 2nd sheet is the weekly roster set out in 12 columns and 57 rows including headers. The 4th - 11th columns are where I have the task/activity that each person will be doing (this represents 1hr 30min period). Each day uses 14 rows including the days header.

    On the 3rd sheet I have got a little matrix that has the shift personnel names and then I have 4 columns following which I want to tally up what task/activity that each person has done.

    The problem that I have is that I have the matrix set up to pull the names off the first days list (the same people are on shift all week), then on the following days I have them in different positions on the roster sheet (2). Therefore on the second day onwards I need to ask excel to lookup where that person is in the roster and then go across and count the tasks that they are on for that day.

    For this I have tried to combine a vlookup with a countif, but to no success. Can I ask if any one out there knows how I may do this or am I using the wrong combination of functions to complete my spreadsheet?

    Any help would be much appreciated.

    Kind regards.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,923

    Re: How do i combine a vlookup function with a countif function?

    Please post a small sample Excel file (NOT image) shoe=wing required results.

    To Attach a File:

    1. Click "Go Advanced"
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  3. #3
    Registered User
    Join Date
    10-25-2016
    Location
    Helston Cornwall
    MS-Off Ver
    MS 2013
    Posts
    4

    Re: How do i combine a vlookup function with a countif function?

    Please find attached (hopefully I've done it correctly), a copy of the work book that my post was asking about.

    Kind regards
    Craig
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,923

    Re: How do i combine a vlookup function with a countif function?

    Can you add some manual "calculations" to count the tasks that they are on for that day.. What is a task : provide a list of these.

  5. #5
    Registered User
    Join Date
    10-25-2016
    Location
    Helston Cornwall
    MS-Off Ver
    MS 2013
    Posts
    4

    Re: How do i combine a vlookup function with a countif function?

    My dilema is that everyone is not always in the same postion on the roster each day, so that I require the formula to look down column C to find that
    person and then to look across the row to count up the gates he/she has.

    I have got sheet3 Gate matrix column B set up to read the names from day 1, and they are not always in the same positions for the remaining 3 days.

    Column G - I have a simple autosum set up her to count the total number of gates for an individual over the 4 days. =SUM(C5:F5)

    Column H - I want the matrix to count up how many last gates people have over the 4 day work roster, using the roster on sheet 2.

    Column I - I want the matrix to count up how many 1st gates people have over the 4 day work roster, using the roster on sheet 2.

    Column J - I want the matrix to count how many days people have done on Wgate and not individual W Gates or W Gate Off, using the roster on sheet 2.

    Column K - I want this to only work off the very last day and indicate which 2 people are doing the last 2 gates (ENT Gate & EX Gate), using the roster on sheet 2.

    In column C and cell C3 I was trying the following formula to see if would find the correct person and then count the number of gates that the person had for that day. The formula that I was trying to use was:
    =AND(VLOOKUP(B7,SHEET2!C3:K15,1,FALSE),COUNTIF(SHEET2!D5:K5,"*?GATE"))

    The return value that I received for this was #VALUE
    Last edited by charris58; 10-29-2016 at 09:36 PM. Reason: Forgot to incorporate my formula & return value

  6. #6
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: How do i combine a vlookup function with a countif function?

    Okay, I'm just going to explain how to do one instead of doing the entire sheet for you, since I'm not sure on what you were asking for anyway...

    =COUNTIF(INDIRECT("Sheet2!D"&MATCH($B5,Sheet2!$C$3:$C$15,0)+2&":K"&MATCH($B5,Sheet2!$C$3:$C$15,0)+2),"*"&"GATE"&"*")
    In cell C5 on sheet 3, then double click it down.

    Now to explain this function...

    I am utilizing indirect to give the range that is described in text within. We are utilizing the match function to find the position of the match in the given range, then applying a correction number so it spits out the row value. Utilizing that trick, you can have it look at all of the correct ranges in your other page, regardless of how you organize the names, etc.

    So for example, in the day two column, it would change to this:

    =COUNTIF(INDIRECT("Sheet2!D"&MATCH($B5,Sheet2!$C$17:$C$29,0)+16&":K"&MATCH($B5,Sheet2!$C$17:$C$29,0)+16),"*"&"GATE"&"*")
    I locked the B column by entering it as $B5, so you can simply drag the formula to the right and adjust it as necessary. If you have a lot of different days, you could make it so every-time you drag it right it auto-does the corrections for you (making it a super complicated formula), but your sample data doesn't suggest this is necessary.

    It would probably be smarter to re-format how your data is than attempting to create a massive formula if manually redo-ing this is too much for you. For example, creating named ranges for each day, then utilizing indirect and the columns function to return everything in that named range. If you called them Day 1, etc.

    =indirect("Day "&columns($A:A))
    Would refer to the given range (and drag right, changing to Day 1, Day 2, etc. instead of having all of the correction factors etc. It would just be a matter of setting up all the named ranges then you could refer back to them easily.

    Hope this helps.
    Last edited by TheN; 10-29-2016 at 10:46 PM. Reason: More info

  7. #7
    Registered User
    Join Date
    10-25-2016
    Location
    Helston Cornwall
    MS-Off Ver
    MS 2013
    Posts
    4

    Re: How do i combine a vlookup function with a countif function?

    TheN

    Firstly, apologises for a timely delay in my reply to you. I have been away for several weeks on a course for work and have not long got back. Thank you for your response to my quandary, I shall now digest your suggestion and try and implement it hopefully with success.

+ 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. [SOLVED] how to combine vlookup with ifcount function
    By rizwan32 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-24-2014, 01:49 PM
  2. [SOLVED] Combine Vlookup and Sumif function
    By HaroonSid in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-24-2014, 01:14 AM
  3. [SOLVED] Countif with vlookup function
    By NJH88 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-13-2014, 11:33 AM
  4. [SOLVED] Writing code for a function to combine iferror and vlookup
    By tommyko in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-31-2012, 05:39 PM
  5. please help how to combine IF function with Countif function
    By Dinesh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-30-2006, 03:35 PM
  6. How do I combine If and VLookup function?
    By Felicia Pickett in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-13-2005, 08:10 PM
  7. How to combine a vlookup with a sumif function!!!
    By Mark the Shark in forum Excel General
    Replies: 2
    Last Post: 04-06-2005, 07:06 AM

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