VBA code for Countifs when there are 3 conditions

NoxGalleon106

New Member
Joined
Oct 15, 2016
Messages
29
Hi,

I am working on a macro wherein it should count the number of cells that meets the following 3 criteria:

1. Range N:N is > 5,000,000
2. Range AE = To prematch
3. Range J:J = next business day

My current codes are as follows but I am not sure on how to integrate the 3 codes. The

SD = Application.WorkDay(Date, 1)
SD1 = Format(SD, "dd\/mm\/yyyy")
B = WorksheetFunction.CountIf(Range("AE:AE"), "To Prematch")
T = WorksheetFunction.CountIf(Range("J:J"), "=" & SD)
H = WorksheetFunction.CountIf(Range("N:N"), ">" & 5000000)

Thanks in advance!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi ,

To count using more than one criterion , you will have to use the COUNTIFS function , as follows :

WorksheetFunction.CountIfs(Range("N:N"), ">5000000" , Range("AE:AE"), "To Prematch" , Range("J:J"), "=" & Format(Application.WorkDay(Date, 1), "dd\/mm\/yyyy"))

 
Upvote 0
Hi ,

To count using more than one criterion , you will have to use the COUNTIFS function , as follows :

WorksheetFunction.CountIfs(Range("N:N"), ">5000000" , Range("AE:AE"), "To Prematch" , Range("J:J"), "=" & Format(Application.WorkDay(Date, 1), "dd\/mm\/yyyy"))


Brill! worked like a charm. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top