+ Reply to Thread
Results 1 to 27 of 27

Countif in VBA with Multiple Conditions

Hybrid View

Dord25 Countif in VBA with Multiple... 01-09-2024, 05:33 PM
romperstomper Re: Countif in VBA with... 01-09-2024, 05:47 PM
Dord25 Re: Countif in VBA with... 01-09-2024, 05:59 PM
romperstomper Re: Countif in VBA with... 01-10-2024, 03:20 AM
Dord25 Re: Countif in VBA with... 01-11-2024, 04:12 PM
protonLeah Re: Countif in VBA with... 01-09-2024, 06:23 PM
Dord25 Re: Countif in VBA with... 01-09-2024, 06:37 PM
protonLeah Re: Countif in VBA with... 01-09-2024, 07:02 PM
Dord25 Re: Countif in VBA with... 01-09-2024, 07:13 PM
TMS Re: Countif in VBA with... 01-09-2024, 07:27 PM
Dord25 Re: Countif in VBA with... 01-09-2024, 08:21 PM
TMS Re: Countif in VBA with... 01-09-2024, 11:25 PM
romperstomper Re: Countif in VBA with... 01-11-2024, 04:54 PM
Dord25 Re: Countif in VBA with... 01-11-2024, 05:40 PM
romperstomper Re: Countif in VBA with... 01-11-2024, 06:43 PM
Dord25 Re: Countif in VBA with... 01-11-2024, 07:46 PM
romperstomper Re: Countif in VBA with... 01-12-2024, 05:13 AM
romperstomper Re: Countif in VBA with... 01-11-2024, 07:50 PM
Dord25 Re: Countif in VBA with... 01-11-2024, 09:22 PM
romperstomper Re: Countif in VBA with... 01-12-2024, 05:09 AM
Dord25 Re: Countif in VBA with... 01-12-2024, 12:43 PM
romperstomper Re: Countif in VBA with... 01-12-2024, 01:50 PM
Dord25 Re: Countif in VBA with... 01-12-2024, 03:01 PM
romperstomper Re: Countif in VBA with... 01-12-2024, 03:06 PM
Dord25 Re: Countif in VBA with... 01-12-2024, 03:11 PM
romperstomper Re: Countif in VBA with... 01-12-2024, 03:24 PM
Dord25 Re: Countif in VBA with... 01-12-2024, 03:40 PM
  1. #1
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Countif in VBA with Multiple Conditions

    Yes, that is true but it is not the case in your code (that is why I asked if either of the other conditions were arrays).

    If you need two arrays, one has to be a vertical array and the other horizontal
    Everyone who confuses correlation and causation ends up dead.

  2. #2
    Registered User
    Join Date
    12-08-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    53

    Re: Countif in VBA with Multiple Conditions

    Quote Originally Posted by rorya View Post
    Yes, that is true but it is not the case in your code (that is why I asked if either of the other conditions were arrays).
    No, they are not, but BrandArray is an array as well. It is variant type and contains codes like 1453, 1698, etc. that are matched on.

    The column I added to the file has the same kind of format of the column in the code above that is not working (with Array(1, 2, 3, 7, 8, 9, 10))

    Quote Originally Posted by rorya View Post
    If you need two arrays, one has to be a vertical array and the other horizontal
    Sorry, I am confused. Is there some documentation on what kind of rule this is? How would it work for the foo macro? Thank you.
    Last edited by Dord25; 01-11-2024 at 09:24 PM.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Countif in VBA with Multiple Conditions

    Quote Originally Posted by Dord25 View Post
    No, they are not, but BrandArray is an array as well.
    Yes, I know, but you are not passing the whole array at once as a criterion, you are passing individual elements one at a time using BrandArray(i). Unless the individual elements of your BrandArray array are also themselves arrays, that is not the issue (your code is posted completely out of context so we can't tell).

    Sorry, I am confused. Is there some documentation on what kind of rule this is? How would it work for the foo macro? Thank you.
    No, because it's not a normal use of countifs. If you use two arrays with the same orientation, the criteria are taken in pairs but what you want is all possible combinations (a Cartesian product). So for example, if you pass the arrays {1,2} and {3,4} as criteria, you would get rows matching 1 and 3, and rows matching 2 and 4 only. You would need the equivalent of {1,2} and {3;4} in formulaic terms.

+ 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. Replies: 5
    Last Post: 03-30-2020, 08:47 PM
  2. Using multiple conditions with countif
    By roberco30 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2019, 01:06 PM
  3. CountIF with multiple conditions one of which needs an OR.
    By Paul Clark in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-14-2014, 10:45 AM
  4. [SOLVED] COUNTIF and multiple conditions
    By Sami in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-28-2005, 05:05 AM
  5. Multiple conditions on a countif
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  6. Multiple conditions on a countif
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. Multiple conditions on a countif
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

Tags for this Thread

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