Unique and Indirect Functions

jwaz73

New Member
Joined
Oct 19, 2022
Messages
8
Office Version
  1. 365
Platform
  1. MacOS
Hello Friends! I'm new to using what I believe are called dynamic functions in Excel. I have successfully used the INDIRECT function in this same sheet like this:
Excel Formula:
=SUMPRODUCT(SUMIF(INDIRECT("'"&tblSheets&"'!AG7:AG26"),K7,INDIRECT("'"&tblSheets&"'!AW7:AW26")))
Obviously, this will return a numeric value.

Now, trying to get a unique list of text like this:
Excel Formula:
=UNIQUE(INDIRECT("'"&tblSheets&"'!AG31:AJ40"))
This results in a #VALUE! error with the details stating "A value used in the formula is of the wrong data type."

What I'm expecting is to get multiple results that 'spill' into the cells below the formula cell.

The format of all cells involved is 'General'. (If that makes any difference.)

What I'm trying to accomplish here is to account for sheets being added to this worksheet, then the tblSheets named range can be adjusted without having to rewrite several formulas.

I'm about five hours into reading about how to use the two functions in this formula and haven't made any progress. Suggestions are appreciated.

-Many Thanks!!
 
How many sheets do you have & are they all contiguous?
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Right now there are three sheets and they are all contiguous. There will be additional sheets added in the future.
 
Upvote 0
In that case you can use a 3D reference like
Excel Formula:
=VSTACK(Sheet1:Sheet3!AG31:AJ40)
 
Upvote 0
I started with this:
Excel Formula:
=UNIQUE(Sheet1:Sheet3!AG7:AJ26)
Doesn't work...

Ended up here:
Excel Formula:
=UNIQUE(TEXTSPLIT(TEXTJOIN(",",TRUE,Sheet1:Sheet3!AG7:AJ26),,","))
This works but the range of sheets is static and adding a sheet to the book will cause me to update formulas in several different places.

I thought about using MIN(tblSheets)!MAX(tblSheets) but reading about those functions, they only work with numbers not text.

Still looking...
 
Upvote 0
Thanks! It looks like the VSTACK function will take the place of the TEXTSPLIT(TEXTJOIN)) complexity and that will help.

Still looking for a way to have the Sheet1:SheetN reference be dynamic...
 
Upvote 0
You can create two "dummy" sheets (which can be hidden) called Start & End then use those in the formula & make sure that any extra sheet go inbetween them.
 
Upvote 0
Solution
Ah, hadn't thought of that. That may be the answer, at least for now... :cool:
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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