+ Reply to Thread
Results 1 to 12 of 12

Add another criteria to a countif routine

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Add another criteria to a countif routine

    Hi

    A member provided the following code to count the contents of WorkSpace!CC based on the list at WorkSpace!G2 (G2-G11) and output results to DATA!D8-D17.

    Please Login or Register  to view this content.
    In plain English this routine counts the number of Units in Workplace!C:C based on the list at WorkPlace!G2 and then outputs the results to Data!D8:D17.

    I would like to count how many males/females/Not recorded are at each Unit. This data is in (WorkPlace!E:E). I have a list at H2 with Male/Female/Not recorded. Males will be stored at Data!D33:D42, Females at Data!E33:E42 & Not Recorded at Data!F33:F42

    Hopes this make sense. Any assistance would be appreciated

    Cheers

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,873

    Re: Add another criteria to a countif routine

    If previous one worked as expected you may try:

    Please Login or Register  to view this content.
    (not tested, as there was no sample file)
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Add another criteria to a countif routine

    Hi,

    thanks for responding. No luck with the code. When I run it, it opens Update Values: Workplace dialog box which seems to want me to upload a file. When I click cancel it closes the dialog box and displays #VALUE! in the output cells. D33 has the formula =COUNTIFS(WorkSpace!C:C,WorkSpace!G2,[WorkPlace]WorkPlace!E:E,TRANSPOSE(WorkSpace!H2)).

    Cheers

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,873

    Re: Add another criteria to a countif routine

    Check carefully sheet names - do you have both WorkPlace and Workspace - you refer to both in post #1
    ... in Workplace!C:C based on the list at WorkPlace!G2 ...
    And as I said - no sample file attached = code not tested See 5th bullet point below numbered rules in http://www.excelforum.com/forum-rule...rum-rules.html

    There is a big chance that as you try to fill right such simple trick as transform would not do. Try (If I was right about your mistake with WorkPlace/WorkSpace):
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Add another criteria to a countif routine

    Hi,
    When I click the Attachments Icon I get the following 18-03-2016 3-13-56 PM.png with no dialog to upload from my local drive. Any ideas?


    cheers.

  6. #6
    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,052

    Re: Add another criteria to a countif routine

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    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

  7. #7
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Add another criteria to a countif routine

    I have followed the instructions> I can select the file from my local drive and upload the file
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Add another criteria to a countif routine

    I have followed the instructions. I can select the file from my local drive and upload the file but cannot locate the done option. The only option I have is to close the page and return to this page. Where I have no indication that a file is attached. Frustrating mechanics.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Add another criteria to a countif routine

    Hi,

    you did well. File is uploded

  10. #10
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Add another criteria to a countif routine

    Well, I'll be damned it uploaded twice. This forums mechanics will take some getting use to. Never mind the assistance is worth it. Thanks for the guide.

    You were right I had WorkPlace where I indeed should have had WorkSpace. My dumb.

    I corrected first code and ran the sheet again. It posted the correct numbers for the first 2 Male counts. All other outputs where 0. In all cases the Range H:xx had incremented by 1.

    cheers,

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,873

    Re: Add another criteria to a countif routine

    As you can see Macro 4 works fine. So discard macro3.

    A standard tool in such cases would be pivot table. It could be used also to prepare tables with age and years in service tables.

    I used it (pivot table) to check output from macro4 - see cells J1 and down/right.

    This whole thread shows how attached sample sheet make life easier.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    09-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Add another criteria to a countif routine

    Thank you for your assistance. I've haven't got to pivot tables yet but its on the list.

    I'll mark this as solved. I wasn't able to add to your rep...It seems I need to spread the love around

    cheers

+ 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] naming a routine and calling it in another routine - not a loop
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2015, 11:54 AM
  2. Return dates that match a single criteria (a countif criteria)
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-07-2014, 12:43 PM
  3. Pass a variable from one sub-routine to another sub-routine
    By gowtham_pec in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-01-2013, 07:07 PM
  4. Conditional Copy Routine with mutliple criteria
    By PhilA in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2013, 08:21 PM
  5. Countif w/ Multiple Criteria-How do I use countif
    By Patrick_KC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2005, 05:05 PM
  6. Countif using format criteria not number criteria?
    By Rumbla76 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-20-2005, 01:06 AM
  7. [SOLVED] Countif using format criteria....not number criteria?
    By Troy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-20-2005, 12: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