Countifs for if not equal to "Exception"

Cakz Primz

Board Regular
Joined
Dec 4, 2016
Messages
102
Office Version
  1. 365
Platform
  1. Windows
Dear all,

I need to count based on 3 criteria, in a userform:

1. based on system number = TextBox1.Value
2. based on status "Active"
3. based on remarks, if not equal to "Exception"

with this code below:
VBA Code:
TextBox5.Value = Application.WorksheetFunction.CountIfs(Sheets("PLREP").Range("B8:B150000"), TextBox1.Value, Sheets("PLREP").Range("G8:G150000"), "Active") - Application.WorksheetFunction.CountIfs(Sheets("PLREP").Range("B8:B150000"), TextBox1.Value, Sheets("PLREP").Range("G8:G150000"), "Active")
it gave me the result = 5, but the correct result should be 4, as we have 1 Exception

And when I am trying to use this code below, it gave me an error, in "Exception":
Code:
TextBox5.Value = Application.WorksheetFunction.CountIfs(Sheets("PLREP").Range("B8:B150000"), TextBox1.Value, Sheets("PLREP").Range("G8:G150000"), "Active") - Application.WorksheetFunction.CountIfs(Sheets("PLREP").Range("B8:B150000"), TextBox1.Value, Sheets("PLREP").Range("G8:G150000"), "Active", Sheets("PLREP").Range("AQ8:AQ150000"), <>"Exception")
How is the correct syntax to count if not equal to "Exception"?

Thanks in advance.
Prima Indonesia
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try changing this condition:
VBA Code:
<>"Exception"
to this:
VBA Code:
"<>Exception"
 
Upvote 0
Solution
D
Try changing this condition:
VBA Code:
<>"Exception"
to this:
VBA Code:
"<>Exception"
Dear Joe4,

Thanks for your help and assistance, the code is working very well.
Thank so much.
Problem solved.

Regards,
Prima Indonesia
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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