VBA: How to countif cell shouldnt be empty and corresponding cell shouldnt be equal to a specific text?

shrinivasshweta

New Member
Joined
Dec 29, 2016
Messages
18
Code:
[COLOR=#333333]arr1=array("d","e","f")[/COLOR]
[COLOR=#333333]For Each elem In arr1[/COLOR]
[COLOR=#333333]a= a + WorksheetFunction.Sum(WorksheetFunction.CountIfs(.Columns(2), "<>specific text", .Columns(13), "<>""", .Columns(7), elem))[/COLOR]
[COLOR=#333333]Next elem[/COLOR]


Can someone tell me a better way to do this?
Thank you so much :)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I think it's always best to tell us in words what your attempting to do. And not show us a script you have that does not do what you want and expect us to fix your script.

Tell us in detail what your attempting to accomplish.

We need Sheet names column numbers and criteria.
And where you want the results entered.
 
Upvote 0
I want to count the total number of a's based on following criteria:

1)cell in Col B shouldn't be equal to "specific text"
2)corresponding cell in col M shouldn't be blank
3) corresponding cell in col G should match with elements of following array
array= "d","e","f"
 
Last edited:
Upvote 0
Try this:
Code:
    With Sheets("YourSheet")
        For i = 1 To Rows(.UsedRange.Row + .UsedRange.Rows.Count - 1).Row
            a = a - CLng((.Cells(i, "B").Value <> "specific text") And _
                (.Cells(i, "M").Value <> "") And _
                (Not IsError(Application.Match(.Cells(i, "G").Value, Arr1, 0))))
        Next i
    End With
 
Upvote 0

Forum statistics

Threads
1,215,416
Messages
6,124,772
Members
449,187
Latest member
hermansoa

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