+ Reply to Thread
Results 1 to 5 of 5

Convert COUNTIFS formula to VBA

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

    Convert COUNTIFS formula to VBA

    Lookingfor help to convert formulas to VBA.

    I have used a combination of COUNTIF & COUNTIFS formulas to calculate the age of members from different departments
    While it works it is slow to execute and cumbersome to manage. Sample Code

    Please Login or Register  to view this content.
    Is there a better way to streamline the formulas in VBA.

    I have attached a example workbook.

    cheers.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Convert COUNTIFS formula to VBA

    Looking at this on an iPad so can't see how you have defined your Named Ranges. Full column references MIGHT slow things down but, in theory, they shouldn't. That said, I'd still avoid them ... better to use Dynamic Named Ranges using INDEX and COUNTA. And they're not R1C1 type formulae, so delete that bit (just the R1C1).
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Convert COUNTIFS formula to VBA

    Note that an 18 year old wil be included in both of the first two formulae.

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

    Re: Convert COUNTIFS formula to VBA

    Thanks for responding
    The named ranges are indeed full column. The 18 year old error is noted, typo on my part.

    I've not used INDEX before, so I'll look into that. I am under the impression that COUNTA did not play well with criteria?

    Are you saying to replace FormulaR1C1 with Formula with the existing code or to use it with INDEX?.

    cheers

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Convert COUNTIFS formula to VBA

    Please Login or Register  to view this content.
    Assuming no blanks in the range, a Dynamic Named Range would look something like:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. Equation convert from COUNTIFS to SUMPRODUCT function
    By husni in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-25-2014, 09:42 PM
  2. How to convert countifs to sumproduct
    By Dzana in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-25-2013, 12:37 PM
  3. HELP CONVERT SUMPRODUCT to COUNTIFS
    By chie in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-09-2013, 07:35 AM
  4. Convert CountIFs into SumProduct
    By gingank in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2012, 09:25 PM
  5. COUNTIFS 2003 - Impossible to convert
    By ADAMD30 in forum Excel General
    Replies: 7
    Last Post: 10-27-2011, 11:27 AM
  6. Convert CountIfs formula to VBA
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-26-2011, 08:55 AM
  7. Convert CountIfs to Office 2003
    By ABBOV in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2011, 09:14 AM
  8. COUNTIFS formula convert to 2003
    By tjlong in forum Excel - New Users/Basics
    Replies: 12
    Last Post: 09-23-2010, 05:41 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