SOLVED

Using the COUNTIF Function to Find Unique Values

%3CLINGO-SUB%20id%3D%22lingo-sub-2251335%22%20slang%3D%22en-US%22%3EUsing%20the%20COUNTIF%20Function%20to%20Find%20Unique%20Values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2251335%22%20slang%3D%22en-US%22%3E%3CP%3EHello!%26nbsp%3B%20I%20have%20an%20Excel%20workbook%20with%20100%2B%20tabs%2C%20each%20containing%20a%20data%20table%20that%20starts%20in%20A12%20(headers%20in%20row%2011)%20and%20spans%20across%20to%20column%20Z.%26nbsp%3B%20In%20cell%20A1%20of%20each%20tab%2C%20I'd%20like%20to%20include%20a%20formula%20that%20counts%20all%20unique%20values%20of%20data%20in%20column%20H%20in%20that%20specific%20tab.%26nbsp%3B%20Currently%2C%20I%20am%20using%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSUMPRODUCT(1%2FCOUNTIF(H12%3AH14%2CH12%3AH14))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EData%20begins%20in%20row%2012%20of%20each%20tab.%26nbsp%3B%20There%20can%20be%20as%20few%20as%20one%20row%20of%20data%20in%20the%20tab%20(going%20to%20H12)%20to%20as%20many%20as%2080%2C000%20rows.%26nbsp%3B%20This%20data%20is%20updated%20regularly%2C%20which%20causes%20the%20number%20of%20rows%20to%20change%20with%20each%20update.%26nbsp%3B%20I%20am%20attempting%20to%20create%20a%20formula%20that%20can%20be%20copied%20to%20all%20100%2B%20tabs%20without%20the%20need%20to%20change%20the%20row%20number%20in%20each%20tab%20after%20each%20update.%26nbsp%3B%20(i.e.%2C%20I%20currently%20have%20to%20change%20%22H14%22%20to%20the%20last%20row%20of%20each%20tab.%26nbsp%3B%20Way%20too%20time-consuming.)%26nbsp%3B%26nbsp%3BI%20replaced%20H12%3AH14%20with%20H%3AH%2C%20but%20no%20luck.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESeeking%20advice%20from%20this%20group%20to%20come%20up%20with%20a%20solution.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2251335%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Hello!  I have an Excel workbook with 100+ tabs, each containing a data table that starts in A12 (headers in row 11) and spans across to column Z.  In cell A1 of each tab, I'd like to include a formula that counts all unique values of data in column H in that specific tab.  Currently, I am using the following:

 

=SUMPRODUCT(1/COUNTIF(H12:H14,H12:H14))

 

Data begins in row 12 of each tab.  There can be as few as one row of data in the tab (going to H12) to as many as 80,000 rows.  This data is updated regularly, which causes the number of rows to change with each update.  I am attempting to create a formula that can be copied to all 100+ tabs without the need to change the row number in each tab after each update.  (i.e., I currently have to change "H14" to the last row of each tab.  Way too time-consuming.)  I replaced H12:H14 with H:H, but no luck.  

 

Seeking advice from this group to come up with a solution.  

 

Thank you!

5 Replies
best response confirmed by mucrick (New Contributor)
Solution

@mucrick 

Let's say that the data in none of your sheets extends below row 100000.

As an array formula confirmed with Ctrl+Shift+Enter:

 

=SUM(IF(H12:H100000<>"",1/COUNTIF(H12:H100000,H12:H100000)))

That semed to solve the issue! Thank you for the quick response and solution!
Thank you, Sergi, for the quick response. Data Tables are being used. I ended up using the solution provided below.

@Sergei Baklan 

A formula from a cell outside a table referring to a table column using structured table refeferences has to include the table name.

Table names have to be unique across the workbook, so you couldn't simply use the same formula in each sheet.

It would be possible to create dynamic named ranges with the same name on each sheet, but that would be extra work...