Modifying a SUMPRODUCT formula.

dougmarkham

Active Member
Joined
Jul 19, 2016
Messages
252
Office Version
  1. 365
Platform
  1. Windows
Hi Folks,

I have the following worksheets: ‘Table' worksheet and ‘data1’ worksheet.
I am looking to design a formula to 'count the number of unique values' in column A of the 'data1' worksheet.

The ‘Table Worksheet’ contains ‘table 1’ with ‘column A’ listing my worksheet names. My goal is to put a formula in column B of the ‘table 1’ that refers to ‘worksheet names’ within column A of ‘table 1’ and then calculates the number of unique values in Column A of the worksheet being referred to (column A in data1 has cell A1 as a header which I do not wish to be included in the count).

E.g. in Table 1: if cell A2 contains ‘Data1’ (the name of the first worksheet), in B2 I would like to put in a formula that reads the contents of cell A2 (‘Data1’) and refers to the worksheet data1 before calculating and returning the number unique values in column A of the ‘Data1’ worksheet.

I found a formula for calculating the number of unique values within a column:
Code:
=SUMPRODUCT((A:A<>"")/COUNTIF(A:A,A:A&""))

I also found a formula for referring to Cell A2 in Table 1
Code:
=INDIRECT(“’”&$A2&”’!”&A:A)

However, I have tried combining these formulas but cannot get it to work.
Any help would be much appreciated!

Kind regards,

Doug
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Like this?


Book1
AB
1SheetUnique Values
2Data14
3Data26
Table
Cell Formulas
RangeFormula
B2=SUMPRODUCT((INDIRECT($A2&"!A:A")<>"")/COUNTIF(INDIRECT($A2&"!A:A"),INDIRECT($A2&"!A:A")&""))


WBD
 
Upvote 0
Like this?

AB
1SheetUnique Values
2Data14
3Data26

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Table

Worksheet Formulas
CellFormula
B2=SUMPRODUCT((INDIRECT($A2&"!A:A")<>"")/COUNTIF(INDIRECT($A2&"!A:A"),INDIRECT($A2&"!A:A")&""))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



WBD

That's done it, thanks WBD!!

In one attempt, I had tried:

Code:
=SUMPRODUCT(((INDIRECT("'"&A26&"'!A:A"))<>””)/COUNTIF((INDIRECT("'"&A26&"'!A:A")),(INDIRECT("'"&A26&"'!A:A"))&”))

so close yet so far...

Many thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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