Formula help with indirect function.

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hello all,

I have a formula that will check for duplicate values in column G.

=SUMPRODUCT((COUNTIF(G5:G1000,G5:G1000)-1)*(G5:G1000<>""))>0

Thing is I want it to check for duplicate values in not just one sheet but in any sheet which is currently active. Hence I have another formula for that in cell.

=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))

So how can I use the indirect function to look for the duplicate values from the sheet name given from the second formula and the range to be taken is G5:G1000

I will appreciate any help on this.

Thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If the formula that produces the sheet name is in cell A1 then your formula would look like this

=SUMPRODUCT((COUNTIF(INDIRECT("'"&A1&"'!$G5:$G1000",TRUE),INDIRECT("'"&A1&"'!$G5:$G1000",TRUE))-1)*(INDIRECT("'"&A1&"'!$G5:$G1000",TRUE)<>""))>0

The reason for the single quotes before and after the A1 reference is in case the sheet name has one or more spaces in it.

As a general comment on the INDIRECT function, it only contains cell references. Any function names, eg SUMPRODUCT or COUNTIF are outside the INDIRECT function.
 
Upvote 0
Solution
If the formula that produces the sheet name is in cell A1 then your formula would look like this

=SUMPRODUCT((COUNTIF(INDIRECT("'"&A1&"'!$G5:$G1000",TRUE),INDIRECT("'"&A1&"'!$G5:$G1000",TRUE))-1)*(INDIRECT("'"&A1&"'!$G5:$G1000",TRUE)<>""))>0

The reason for the single quotes before and after the A1 reference is in case the sheet name has one or more spaces in it.

As a general comment on the INDIRECT function, it only contains cell references. Any function names, eg SUMPRODUCT or COUNTIF are outside the INDIRECT function.

I have an upcoming task that involves the Indirect function. I'll keep that in mind and thanks for the tip.
 
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,925
Members
449,056
Latest member
denissimo

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