Adding CountIf to Array Formula

MattH1

Board Regular
Joined
Jul 15, 2016
Messages
174
Hey everyone,
I hope someone is able to help me edit this array formula, I've attempted multiple times to add it myself but it seems to not like me very much....

Here is the formula:
Code:
=SUM(IF(FREQUENCY(IF(V(arrayunion([COLOR=#ff0000]TABONE!B2:B10000,TABTWO!B2:B10000,TABTHREE!B2:B10000[/COLOR]))<>"",MATCH(V(),V(),0)),ROW(INDIRECT("1:"&COLUMNS(V())))),1))

The VBA code is as follows:
Code:
Function ArrayUnion(ParamArray Arg() As Variant) As Variant
    ' Code: Juan Pablo González
    ' Spec: Aladin Akyurek
    ' May 4, 2003
    ' Ref: [URL="http://makeashorterlink.com/?P20022174"]TinyURL.com - shorten that long URL into a tiny URL[/URL]
    Dim TempUnion() As Variant
    Dim i As Long, Itm As Variant, Ctr As Long
    For i = LBound(Arg) To UBound(Arg)
        Arg(i) = Arg(i)
        If IsArray(Arg(i)) Then
            For Each Itm In Arg(i)
                Ctr = Ctr + 1
                ReDim Preserve TempUnion(1 To Ctr) As Variant
                TempUnion(Ctr) = Itm
            Next Itm
        Else
            Ctr = Ctr + 1
            ReDim Preserve TempUnion(1 To Ctr) As Variant
            TempUnion(Ctr) = Arg(i)
        End If
    Next i
 ArrayUnion = TempUnion
 End Function

 Public Function V(Optional vrnt As Variant) As Variant
 '
 ' Stephen [COLOR=#417394]Dunn
[/COLOR]' 2002-09-12
 '
 Static vrntV As Variant
 If Not IsMissing(vrnt) Then vrntV = vrnt
 V = vrntV
 End Function

This code seems to work fine (the red is what I've changed from the source line given to me) when it comes to finding the total number of unique values along these three tabs in Column B. I would like to edit this code to add an IF/COUNTIF statement (whichever would work). I just want it to read the Value of A2 in the sheet where I enter the formula and find the unique number of values in Column B across all of the tabs for THAT value (which will be located in Column C of each tab) I hope this was clear and if not, I'm more than happy to clear it up more.
 
Last edited:
I tried filtering the data and switching SUM() to SUBTOTAL(9,) and that yielded #VALUE, so that didn't seem to work haha.
 
Upvote 0

Forum statistics

Threads
1,226,812
Messages
6,193,116
Members
453,777
Latest member
Miceal Powell

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