+ Reply to Thread
Results 1 to 19 of 19

COUNTIF and VLOOKUP

  1. #1
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    COUNTIF and VLOOKUP

    I am working on attendance calendars. But it is possible that Employees/ID's are on different rows in the monthly calendars.
    Is there a way to do COUNTIF and VLOOKUP when the data isn't always on the same row?
    Much appreciated.
    Attached Files Attached Files

  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
    28,364

    Re: COUNTIF and VLOOKUP

    Look at COUNTIFS where the first criteria (for you) is your ID.

    The postedfile references another file [Copy of PCR Attendance 2016.xlsx] which is not available,

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,815

    Re: COUNTIF and VLOOKUP

    As you are not using column A on the Summary sheet, you can put this formula in cell A4:

    =IFERROR(INDEX(Employee!C:C,MATCH(C4,Employee!D:D,0)),"")

    then copy down - it returns the employee number when it recognises a name in column C (Hint: change the names in C11 and C18 to ones that are in your table of employees).

    Then you can put this formula in cell E4:

    =IFERROR(COUNTIF(INDEX(INDIRECT("'"&E$2&"'!E11:AI43"),MATCH(VLOOKUP(LOOKUP(99999,$A$4:$A4),Employee!$C:$D,2,0),INDIRECT("'"&E$2&"'!B11:B43"),0),),$D4),"")

    and this can be copied across and down your table as far as you need it. The attached file demonstrates this (I've added some made-up data to the JAN and FEB sheets to test it out).

    Hope this helps.

    Pete
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    Pete, you are a freaking genius! Once again you've made sense of this muddle brain of mine and pulled it out for me. I was just about to apologize to JohnTopley. I really do suck at clarity and concise explanations here and history has shown that for as hard as I try there is always at least one stupid oversight in everything I post. Pretty sure it must drive some of y'all here crazy. But Pete - moments like this when I'm understood even through the muddle, it gives me a little boost and I hear myself saying, "Rock on, Brenda." And I keep plugging. And the "Pete moments" are such an awesome gift for the muddle and morale. Rock on, Pete. And thanks again!

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,815

    Re: COUNTIF and VLOOKUP

    You're welcome, Brenda - thanks for the kind words.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post and mark this thread as SOLVED.

    Also, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  6. #6
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    Pete. I had it. Understood it. Made a few changes. Broke it. Would you mind taking a look at your formula if you have a minute. Pls. https://www.excelforum.com/excel-gen...d-vlookup.html

  7. #7
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,443

    Re: COUNTIF and VLOOKUP

    Marked as unsolved. Please attach new, broken file here.
    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.

  8. #8
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: COUNTIF and VLOOKUP

    Quote Originally Posted by BDD2015 View Post
    Hi shukla.ankur

    No, there are no external files. Thought I removed everything. All formulas have been removed from JAN calendar. Maybe you're looking at FEB which I just left in as a master for the formulas?
    See Highlighted part of Summary Sheet formula

    =IFERROR(COUNTIF(INDEX(INDIRECT("'"&E$2&"'!E11:AI43"),MATCH(VLOOKUP(LOOKUP(99999,$A$4:$A5),'G:\BD\Work\Helene Gregoire\[Copy of ef1137_bd RESTUCTURE.xlsm]Data_Validation_List'!$C:$D,2,0),INDIRECT("'"&E$2&"'!B11:B43"),0),),$D5),"")
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  9. #9
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    lol
    Thank you.
    Thought once a thread was marked as "Solved" you couldn't go back. Which is why I started a new thread. Maybe I missed something? I'll check closer next time I break something. I will repost. Thanks again.

  10. #10
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,443

    Re: COUNTIF and VLOOKUP

    Please DO NOT start yet another new thread - if you do, I shall close it. Continue here.

  11. #11
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    Meant repost as in continue not start a new thread. Thanks.

  12. #12
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,443

    Re: COUNTIF and VLOOKUP

    Great! Thanks.

  13. #13
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    I had a functioning COUNTIF/VLOOKUP (thanks to Pete_UK but I made a few adjustments and broke it. Apologies to Pete_UK.
    The original code totalled up Leave Codes for employees, regardless of the calendar month or their position within the calendar on the Summary Sheet.
    Only Jan and Feb are included with the WS. The rest of the months will be added later.
    Attached Files Attached Files

  14. #14
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,815

    Re: COUNTIF and VLOOKUP

    You don't really need that ID2 now in column A, as it is the same as column B.

    There are two problems with the formula - your ID numbers are now 6 or more digits (they were only 3-digits before), and so the 99999 needs to be increased, and the lookup should start with $A$3:$A3. Here's a revised formula for E3 in the Summary sheet, with changes shown in red:

    =IFERROR(COUNTIF(INDEX(INDIRECT("'"&E$2&"'!E11:AI134"),MATCH(VLOOKUP(LOOKUP(999999999,$A$3:$A3),Data_Validation_List!$C:$D,2,0),INDIRECT("'"&E$2&"'!B11:B134"),0),),$D3),"")

    The 999999999 can be any number larger than what you expect for your IDs, eg. 1E100

    Hope this helps.

    Pete

  15. #15
    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
    28,364

    Re: COUNTIF and VLOOKUP

    Try

    in E3

    =IFERROR(COUNTIF(INDEX(INDIRECT("'"&E$2&"'!E11:AI134"),MATCH(VLOOKUP(LOOKUP(999999,$B$3:$B3),Data_Validation_List!$C:$D,2,0),INDIRECT("'"&E$2&"'!B11:B134"),0),),$D3),"")

    Column A now appears redundant.

  16. #16
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    Aw... Wondered what the 99999's were for. Would never have thought about increasing them. And I figured the same thing about Col A but wasn't gonna tackle that until I figured out the primary screw-up. Mission accomplished. Thank you once again Pete. Sorry for the prob.

    Brenda

  17. #17
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: COUNTIF and VLOOKUP

    Exactly! Col. A gone and the reminder to change the range to B was appreciated. And the 999999? Who knew? Me, now lol Answers and lessons from my muddle makes Brenda a Happy Camper once again. And off... Thanks as well JohnTopley.

  18. #18
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,815

    Re: COUNTIF and VLOOKUP

    Quote Originally Posted by BDD2015 View Post
    ...Sorry for the prob...
    Well, the problem was for you, not me.

    Glad you got it sorted in the end - I think you can now mark this (and your other thread) as SOLVED.

    Pete

  19. #19
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,443

    Re: COUNTIF and VLOOKUP

    The duplicate thread is locked, so I have marked it solved.

+ 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] Need help with Countif with vlookup!
    By Rajesh CR in forum Excel General
    Replies: 5
    Last Post: 09-01-2016, 07:48 PM
  2. [SOLVED] Countif And or Vlookup And help
    By Blake 7 in forum Excel General
    Replies: 6
    Last Post: 01-26-2015, 08:12 AM
  3. [SOLVED] VLOOKUP COUNTIF help?
    By sowdani in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-23-2014, 10:49 AM
  4. [SOLVED] VLOOKUP and COUNTIF
    By opsanalysis07 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-04-2014, 07:05 PM
  5. countif and vlookup
    By mkim in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-01-2012, 07:12 AM
  6. countif and Vlookup
    By sagar in forum Excel General
    Replies: 11
    Last Post: 02-13-2007, 10:10 PM
  7. Countif or Vlookup
    By praveen_khm in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2006, 04:17 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