Results 1 to 27 of 27

Countif in VBA with Multiple Conditions

Threaded 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
    Registered User
    Join Date
    12-08-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    53

    Countif in VBA with Multiple Conditions

    Hi,

    I am trying to create a VBA Countif function with an OR condition inside if one of the following values is found. For instance, in this code:

    numerator = WorksheetFunction.Sum(Application.CountIfs(.Range(.Cells(2, colorColumn), .Cells(LastRow, colorColumn)), red, _
                        .Range(.Cells(2, brandColumn), .Cells(LastRow, brandColumn)), BrandArray(i), _
                        .Range(.Cells(2, purposeColumn), .Cells(LastRow, purposeColumn)), 1, _
                        .Range(.Cells(2, materialColumn), .Cells(LastRow, materialColumn)), Array(1, 2, 3, 7, 8, 9, 10))) + _
                        WorksheetFunction.Sum(Application.CountIfs(.Range(.Cells(2, colorColumn), .Cells(LastRow, colorColumn)), blue, _
                        .Range(.Cells(2, brandColumn), .Cells(LastRow, brandColumn)), BrandArray(i), _
                        .Range(.Cells(2, purposeColumn), .Cells(LastRow, purposeColumn)), 1, _
                        .Range(.Cells(2, materialColumn), .Cells(LastRow, materialColumn)), Array(1, 2, 3, 7, 8, 9, 10)))
    Here, the numerator would contain the count of cells with colors red or blue in the colorColumn, for the i index in the BrandArray in the brandColumn, with a purpose of 1 within the purposeColumn, with the material codes of 1,2,3,7,8,9, or 10 in the materialColumn. But I must be doing something wrong because the code only checks for 1 in the materialColumn, not the full list of numbers (the rest of the code works as normal).

    Do I have the syntax wrong for how to perform this?

    Thank you.
    Last edited by Dord25; 01-09-2024 at 05:56 PM.

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