Tag Archives: 3D

#Excel Impossibly Easy #1: Return a 1D Array from Non-Contiguous Native 3D Ranges


What if I told you that I had 2 non-contiguous 3D ranges in an Excel workbook and I wanted to return a single 1D array from those ranges. Impossible, right? No, it turns out that it is “easy”.

Prior to the introduction of the TEXTJOIN function, this would likely have been impossible. But, this function accepts native 3D ranges as range arguments. See:


It would have been nice if the technique was only a VBA solution, but although Textjoin is a VBA worksheet function in Excel, VBA will not accept a native 3D range as an argument. Likewise, a pure Excel formula solution would have been nice, and a method dows exist to do this


but it has severe limitations which prevents its use with a relatively large number of cells (maybe 150). The total number of characters that a cell can contain is 32,767 characters. This solution assumes that an average of 6 characters per cell plus a comma for each gives an approximate number of 4500 cells allowed.

Here is the solution.


It consists of the TEXTJOIN worksheet function with 2 non-contiguous 3D ranges arguments


And a simple VBA function which converts a comma delimited string into a 1D array.

Function ArrayFromCDS(MyString As String)

ArrayFromCDS = Split(MyString, “,”)

End Function

In the example file, the array produced contains all of the elements of the two 3D ranges (shown below).


The figure shows this formula in cell I2.


I hope that you will find this useful.

The example file can be downloaded here.


#Excel Native 3D Ranges with the TEXTJOIN Function Plus Bonus by David Hager

In a conversation with Bill Jelen about the TEXTJOIN function, he mentioned whether I had tried using 3D references as arguments. I said that I had not tried native 3D ranges, and I did not believe it would work. Well, I was wrong (again). It does work, in spite of there being no documentation from Microsoft about that ability. The figure below shows the result in cell D2 of using this formula:



I continue to be amazed by the myriad of formula solutions made possible by the TEXTJOIN function. In a recent article where I demonstrated the use of non-contiguous ranges


I now realize that the same concept can be used with 3D ranges. (Here is the bonus!) In fact, that 3D range can be in ANOTHER workbook, as shown below.



The example file can be downloaded here (Note: I did not include the external file, and I put a tilde in front of that formula)


Remember again, that you have to have the Excel version included in Office 365 in order for the TEXTJOIN formula to work.

#Excel: Using Conditional Formatting to Highlight 3D Formulas with Defined Names by David Hager

There was a comment on LinkedIn about my post about using CF to highlight 3D formulas

“Since I never use a direct reference (or, come to that, enter a formula without naming the range to which it applies) any 3D reference I might use would pass under the radar. Unless, of course, you have an array UDF which will parse the formula to yield a set of references; in which case can I put in an order?”

Initially, I replied that it was not possible. But, the challenge was irresistable. I started working on the problem and, after a number of dead-ends, I was able to come up with a solution. It required a VBA function to return an array of defined names.

Function DefinedNameArray() As Variant


Dim Arr As Variant

nCount = ActiveWorkbook.Names.Count

ReDim Arr(1 To nCount)

For N = 1 To nCount

cPos = InStr(1, ActiveWorkbook.Names(N).RefersTo, “:”)

ePos = InStr(1, ActiveWorkbook.Names(N).RefersTo, “!”)

If cPos < ePos Then

Arr(N) = ActiveWorkbook.Names(N).Name


Arr(N) = “”

End If



DefinedNameArray = Arr

End Function

What the VBA function does is return an array of defined names, but only places the items meeting the correct criteria for a 3D formula in the final array (which is the same concept using in the initial article).


In this case, the InStr function was used to locate the positions of the first colon and exclamation point in the RefersTo string and the values are compared. If cPos<ePos, then the name is added to the array and a null string added otherwise. This array is used in the following formula to find if a 3D defined name is part of the string returned by the FORMULATEXT function. It was defined for use as a CF formatting formula, as shown below (F5 was the active cell when defined).



Both F5 and F7 contain formulas using 3D defined ranges.

Peter, thanks for the challenge!

You can download the example file here.


#Excel: Using Conditional Formatting to Highlight Cells Containing Native 3D Formulas by David Hager

Conditional formatting (CF) in Excel can be used to hightlight cells that meet certain criteria. In this case, I wanted to create a CF that would highlight cells containing formulas that use Excel’s native 3D references. So, this would be like the following example.


So, I tried to determine what was unique this type of formula string compared to others. What I noticed was that the first colon in this formula always comes before the exclamation point. Thus, I started working on a solution on that basis.

Note, though, that there are ways to write a formula containing a 3D reference that will not meet this criteria, such as:


So, don’t use those kinds of formulas. 😊

To lookup the position of the colon in the formula string, the following formula is needed.


where F6 contains the formula.

The corresponding formula for looking up the position of the exclamation point is:


By comparing the two formulas, the following Boolean expression wrapped in an IFERROR function is defined as Is3D:


Applying this formula as a CF on cell F6, you can see that F6 is highlighted as expected.


You can download the example file here.


Using the Excel TEXTJOIN Function To Return Unique Items In A One-Cell Delimited String From A 2D and 3D Range By David Hager

The TEXTJOIN function was recently introduced in Excel 2016, and a number of fascinating formula solutions have been created with this function. One of these formulas used TEXTJOIN to create a one-cell delimited string of unique items from a list. To see how that was done, go to:


The methodology for making a 1D array from a 2D Excel range was created and described in great detail at:


It was subsequently used to make a unique list from that range. The following formula uses a slightly modified version of that methodology.




where the required defined named formulas are:


Range1 =Sheet1!$H$2:$L4)






Again, these formulas were not created by me, but the TEXTJOIN shown above does create a one-cell comma-delimited string from the 2D range Sheet1:!$H$2:$L4).

For a VBA solution to this same problem, see:


I needed a way to transform a 3D range in Excel to a 2D array. Luckily, this had already been done recently. Here is the formula:


This formula was created by MichaelCH as part of the collaboration at the amazing excelxor.com site.

See: https://excelxor.com/2016/04/08/advanced-formula-challenge-13-single-array-containing-all-entries-from-a-given-range-in-multiple-worksheets

Since this formula creates a 2D array from a 3D array, I was hopeful that it could be used in the same way that a “real” Excel 2D range is transformed to a 1D array. In particular, I was concerned that the COLUMNS function would not work on a 2D array, but it did! I just had never tried it before.

In order to modify Arry1 for correct scaling for the 3D range, the following defined formulas were needed:


Sheets={“Sheet1″,”Sheet2″,”Sheet3”,”Sheet4”}  ‘in this example



The modification of Arry1 to 3D scaling is shown below:



along with the other transform array formulas.





The resulting formula using TEXTJOIN affords the desired one cell delimited string on unique items from a 3D range.




Apart from using the created array with TEXJOIN, the transforming of a 3D range in Excel to a 1D array is also noteworthy.

Here is the link to download the file. Remember though, that you have to have the Excel version in Office 365 in order for the TEXTJOIN formulas to work.


EXCEL 3D – Easy as 1-2-3 and A-B-C and Others

EXCEL 3D – Easy as 1-2-3 and A-B-C and Others

By David Hager

A number of years ago (~16) Laurent Longre discovered that Excel formulas that calculated over 3D ranges could be made by using the INDIRECT function(see Issue #3).


This formula was developed out of necessity, since many of the functions in Excel do not work with Excel’s built-in 3D cell range notation.

This methodology was refined to formulas of the general form:


In its basic form, it was first developed sometime in the 2004-2005 time period, but it is unclear who was actually the first person to derive the “final” form.

A specific example of this


This article is not actually about how to use these 3D formulas. Rather, it is about the formula techniques that can be used to create multi-sheet range in the SOMETHING part of the formula.

In each example shown here, an actual formula/range can be used, or a defined name representing the formula/range can be used.  In the following example, an array created by the ROW function can be used to return sheet tabs named as single digit numbers.


Or in the defined name form:

MyNumberTab1 =ROW($1:$4)


It is important to note that this type of 3D formula has another inherent advantage over Excel’s normal 3D range formulas (i.e. – =SUM($1:$4!B2:F2). The tabs do not have to be contiguous for the formulas to function as intended/desired. If, for example, the sheet containing the 3D formulas was “between” sheet “1” and “3” and had entries in the cell range of that sheet, they would be included in the sum for an Excel-inherent 3D cell reference, but they are not for the INDIRECT 3D reference form.

Another formula returns an array of single letters from a-z.


So, using this in the INDIRECT formula will return the expected values for the specified formula from all sheets named a-z (26 sheets). Note that all 26 sheets have to exist for the formula to not return an error. Of course, this formula can be modified for an alphabet subset if necessary.

Another formula returns an array of months of the year, which is another popular choice for naming worksheet tabs.


All of the formula arrays mentioned in this article can be modified by concatenating a text string to the array. In this case, the following array returns 12 strings, starting with “Jan 2011”.

Months2011 =TEXT(ROW($1:$12)&”-1″,”MMM”)&” 2011″

The final example illustrates the simplest form of an array to be used: a simple cell range.


Two modifications of this can be useful as well. The OFFSET function could be used to create a dynamic cell range that would expand or contract based on user input.

For cases where the name list is anticipated to be static, the cell range can be evaluated in the formula bar and the resulting array of tab names can be stored as a defined name.


I hope that you found this discussion useful.