+ Reply to Thread
Results 1 to 8 of 8

Convert a Max(CountIFS()) function to VBA

  1. #1
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Convert a Max(CountIFS()) function to VBA

    Hi,

    I worked for about an hour looking for the correct VBA syntax to do the yellow cell in the attached. Is it possible to do a VBA function to give the maximum number matches between two sets of numbers? In Excel normal functions it is a #Spill so perhaps VBA won't do it??

    The Excel Function is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    VBA for Max(CountIFS()).xlsm
    Last edited by MarvinP; 03-07-2020 at 05:24 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    See first the Evaluate VBA inner help, a must read.

    So in VBA it's the same than under Excel : Debug.Print Sheet1.[MAX(COUNTIFS(B1:K1,B2:K2))]

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert a Max(CountIFS()) function to VBA

    Perhaps next function could help
    It gives the same results as the Excel formula, but it is only counting macthings from Set1 vs Set2 like the formula, is it what you need ?
    If not the function can be updated
    Please Login or Register  to view this content.
    Attached Files Attached Files
    - Battle without fear gives no glory - Just try

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert a Max(CountIFS()) function to VBA

    A remake to take care about previous comment.
    Chose the one you want
    Please Login or Register  to view this content.
    Last edited by PCI; 03-07-2020 at 05:19 PM.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Convert a Max(CountIFS()) function to VBA

    Hi PCI,

    On row 75 I have a problem. Both your codes above give 1 but doing a Find Dups using CF there are two numbers that are duplicates between these two rows. Am I missing something? See the attached.

    Should be 2 matches not 1.xlsm

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert a Max(CountIFS()) function to VBA

    The formula gives also 1, it is counting the nb of times a number is duplicated, here once, not the amount of duplications.

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Convert a Max(CountIFS()) function to VBA

    Maybe

    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Convert a Max(CountIFS()) function to VBA

    If a number occurs multiple times in set 1, then each match in set 2 is counted. E.g . two occurrences in set 1 and two in set 2 will give a count of 4...
    Please Login or Register  to view this content.
    Ben Van Johnson

+ 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] Convert Countifs function to macro .
    By I need excel help in forum Excel General
    Replies: 3
    Last Post: 01-08-2018, 06:47 AM
  2. Convert COUNTIFS formula to VBA
    By ExcelRonin in forum Excel General
    Replies: 4
    Last Post: 03-31-2016, 03:33 AM
  3. Equation convert from COUNTIFS to SUMPRODUCT function
    By husni in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-25-2014, 09:42 PM
  4. How to convert countifs to sumproduct
    By Dzana in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-25-2013, 12:37 PM
  5. HELP CONVERT SUMPRODUCT to COUNTIFS
    By chie in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-09-2013, 07:35 AM
  6. Convert CountIFs into SumProduct
    By gingank in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2012, 09:25 PM
  7. Convert CountIfs formula to VBA
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-26-2011, 08:55 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