Advanced Formula Challenge #13: Single Array Containing All Entries From a Given Range in Multiple Worksheets 20

The challenge this week is as follows: a single formula to return an array which consists of all entries (of potentially mixed datatype) from a given range in multiple worksheets.

No restrictions are placed on the dimensions of the returned array.

For example, using the attached file (download here), the formula should return an array such as:

{18,"",19,63,"","",67;"",46,"","","L","",7;"N","Z","","F",70,19,"";"","","","","","",73;"","","T","","",88,"Y";"U","","B","F","Q",71,"";"","H","U","R",86,84,"Q";11,"R",84,"","",43,72;39,53,"","","R",60,80;"","V","B",33,"",46,39;"","B","","","V","","";"P","","M","","","",85;"O","",9,"","","","";"","I",9,"","S","S",59;"","X","J","","","","X";46,72,"",22,"",67,"P";35,32,69,"O","","","V";24,"","","","R","","";"",5,"B",69,"C","","";"P","A",19,"","","K","B"}

or a dimensional variation thereof.

For the sake of consistency, the specified range (A1:G4 in the attached example) should be referred to as the Defined Name Rng in any formulas. Likewise for any references which refer to a collection of worksheets, e.g.:

={"Sheet1","Sheet2","Sheet3","Sheet4","Sheet5"}

which should be given the Defined Name Sheets.

Also please note that this is not a Shortest Formula Challenge! Hence rigour should be preferred over brevity in any solution.

Solution next week. Good luck!

Advanced Formula Challenge #12: Results and Discussion 2

Last week I set readers the challenge which can be found here.

Such was the number and variety of responses to this challenge that presenting a detailed breakdown of one such solution – as has been the case for all of the first eleven in this series of challenges – would, I feel, be somewhat inappropriate.

For the majority of these challenges, it could be argued that there has been one solution which is indisputably “better” than the rest. Perhaps such an adjudication can also be made here, though to do so would certainly not be a straightforward exercise. What’s more, to pick just one of the many solutions would be to leave the rest – unfairly in my opinion – left on the sidelines.

As such, I would refer the readers to the many solutions in that post and to enjoy dissecting the varied and wonderful constructions therein. And to simply thank all those – Alex, aMareis, Maxim, John Jairo, sam, Jeff, Lori, Ron, Michael, Christian and XLarium – whose excellent contributions led to such a fruitful and inspiring discussion.

There’s evidently still much to be discovered in the world of worksheet formulas!

Another challenge to follow shortly. Watch this space!

Advanced Formula Challenge #12: An Array of Matches 79

The challenge this week is as follows: given a range of arbitrary size in which each entry is either 0 or 1 and in which each row contains at least one occurrence of a 1, a single formula to return an array consisting of the relative column positions of the first occurrence of a 1 within each row.

For example, given the below in A1:E10:

An Array of Matches

the solution would be the array:

{2;1;1;2;1;5;1;4;1;3}

Readers may reference the range A1:E10 in their solution, though of course being aware that this choice is purely arbitrary and hence that any solution must also hold for a range of any size.

Readers should also note that the entries in the returned array are to be the relative column positions within the range (just as if we’d used MATCH on each of the rows within that range). As such, moving the above range to, for example, H1:L10 would have no impact on the output of any solution.

Also note that this is NOT a shortest formula challenge!

Solution next week. Good luck!

Advanced Formula Challenge #11: Results and Discussion 11

Last week I set readers the challenge which can be found here.

Good results for this one: six answers received, six correct answers received – from Oscar, Daniel, diondan1, Bill, Ikkeman and Calvin. Plus one (unverifiable, though no doubt correct!) Google Sheets solution from Isai, as usual. 🙂

So congratulations to all of the above!

The majority of those solutions adopted a strategy of comparing the characters from two sets of arrays derived using MID over an array of start_num parameters, though a couple of solvers (Bill and Calvin) decided to first derive the ASCII codes for these characters and instead use these as the basis for the comparison.

More…

Advanced Formula Challenge #11: All in Order 28

The challenge this week is as follows: given a value in A2, where A2 is a string consisting of upper-case letters of the alphabet only and of minimum character-length 2, a formula to be entered into B2 such that, if and only if the individual characters within the string in A2 are in ascending alphabetical order (from left to right), return TRUE; otherwise return FALSE.

Examples below:

All in Order

(You can download the workbook here.)

Solution next week. Best of luck!

Advanced Formula Challenge #10: Prime Factorisation 22

The challenge this week is as follows: given a value in A2, where A2 is an integer and 2<=A2<=100, a formula to be entered into B2 such that, if the value in A2 is a prime number, return "Prime"; otherwise, return a string representing the prime factorisation of that number, using the full notation as given in the below examples (where a lower-case "x" is used to denote multiplication).

Prime Factorisation

For those not sure of any results, I have given a full list in the attached here.

Solution next week. Best of luck!

Advanced Formula Challenge #9: Results and Discussion Reply

Last week I set readers the challenge which can be found here.

One correct solution received, courtesy of Lori, who not only presented a fine construction for working in Excel 2010 and earlier, but also a 2013 version, which had the added benefit of taking advantage of some of the new (and evidently very useful) features of that version to noticeably abridge the required set-up. So many thanks to Lori for sharing this knowledge and also congratulations on an excellent solution to a particularly complex challenge!

More…

Advanced Formula Challenge #9: One Per Row, One Per Column 8

The challenge this week is as follows: given a 4×4 grid, here in A1:D4, in which each entry is a single-digit integer, and also a target value, here in F2, which is also an integer, though ranging from 1-36, a single formula in G2 to return the number of combinations of four distinct values from that grid whose total is equal to the value in F2, subject to the condition that each of those four values cannot occupy the same row or column as any of the other three.

In the example below, the answer would be 6:

One Per Row, One Per Column

since the following are the only 6 arrangements which meet the conditions outlined above:

One Per Row, One Per Column (2)

Solution next week. Best of luck!

Advanced Formula Challenge #8: Results and Discussion 2

Last week I set readers the challenge which can be found here.

At the time of writing (Saturday morning, UK time; apologies if anyone has submitted something after that date), two correct solutions received (or three if you count non-Excel-based ones: as he has done for most of the recent challenges, Isai Alvarado produced a solution applicable to Google Sheets, which, as usual, I am unable to verify! So I’m taking your word for it that it’s perfectly correct, Isai! 🙂 ).

The two correct entries came courtesy of Snakehips, who gave a rather lengthy but perfectly correct solution, and John Jairo V, who improved upon his earlier attempt by producing a solution which, in essence, used a similar approach to Snakehips’ but which made use of some very nice technique involving MMULT to considerably abbreviate the required construction. Great work, John!

More…

Advanced Formula Challenge #8: Facetious? Moi? 25

The challenge this week is as follows: given a single paragraph of text in A1, which may or may not contain punctuation, a single formula in B1 to identify the number of words within that text which contain all five vowels of the English alphabet precisely once each and in an order of appearance, from left to right, of a, e, i, o, u.

For the below example the result would be 8, as highlighted in red.

Advanced Formula Challenge 8 Facetious Moi v2

Edit: I have now amended the text to make it clearer that certain words are not to be considered in the count: those in black, for example, do not meet the requirements as outlined above.

The workbook can be downloaded here.

Solution next week. Best of luck!

Advanced Formula Challenge #7: Results and Discussion 1

Last week I set readers the challenge which can be found here.

This is a trickier problem than it at first appears, and indeed there are several pitfalls which prevent us from using more “standard” techniques to arrive at a solution.

Perhaps the two main (hidden) obstacles, which were not immediately obvious from the examples I gave, are, firstly, the fact that we are prevented from using a construction involving a SEARCH-approach (e.g. by locating occurrences of each substring of the four types *????*, †????*, *????† and †????†, as John Jairo V attempted), since this of course presumes that there is only one occurrence of each of those substring types within our string, a presumption which cannot be made.

More…

Advanced Formula Challenge #6: Results and Discussion Reply

Last week I set readers the challenge which can be found here.

This one was perhaps a little less complex than ones I’d set in previous weeks, though of course it would still, in my opinion, fall within the boundaries of what I would deem “advanced Excel”.

It also demonstrates some techniques which we can apply to solving problems involving non-contiguous ranges, and in particular tell us which functions may be applicable to such set-ups.

Two good solutions received from John Jairo V and cyrilbrd (and Bill‘s was practically there as well, but for a small amendment – and the fact that I didn’t structure the question in full to begin with – sorry!).

More…

Advanced Formula Challenge #6: Occurs once, non-contiguous range 9

The challenge this week is as follows: given a non-contiguous range, made up of an arbitrary number of single-column ranges, the values in each of which being either a numeric, text or null string, to generate a list, in numerical order and beginning in A2, of all numbers which occur precisely once within that range.

For example, in the below:

Occur Once Non-Contiguous Ranges

More…

Advanced Formula Challenge #5: Results and Discussion 5

Last week I set readers the challenge which can be found here.

This is a reasonably complex problem, and certainly so if we want to present a solution which is relatively concise. However, despite its complexity (and arguably lack of practical use), the solution demonstrates some important techniques for working with strings, and so is not without merit.

The required set-up is as follows:

More…

Advanced Formula Challenge #5: Threes, Fives and Sevens Reply

The challenge this week is as follows: given an alphanumeric string of arbitrary length in A1, derive a single formula to return the number of numbers within that string which are divisible by either 3, 5 or 7.

By “divisible” here I mean of course that there is no remainder after division.

And by “numbers within that string” I mean all consecutive substrings of any length within that string which may be interpreted as a number. (It can also safely be assumed that there are no alphanumeric combinations within the string in A1 which would be interpreted by Excel as numeric, e.g. JAN01.)

For example, the string:

XX30X5XXX42XX771

contains, by this definition, 13 numbers: 3, 0, 30, 5, 4, 2, 42, 7, 7, 1, 77, 71 and 771.

More…

Advanced Formula Challenge #4: Results and Discussion Reply

Last week I set readers the challenge which can be found here.

This one turns out to be a good deal more complex than it at first appears, and so perhaps not surprisingly no correct results were received..

GreasySpot at first thought that Advanced Filter would be a viable solution, but quickly realised that it wasn’t actually appropriate here. Besides, as I mentioned, the idea of this (and of all these challenges in fact) is to try to achieve the results using worksheet formulas alone.

So how can we achieve our desired results?

More…

Advanced Formula Challenge #3: Results and Discussion 3

Last week I posed readers the challenge which can be found here.

One solution was received, again from Bill, and this time it was not only correct, but a very good solution indeed. So congratulations again to Bill!

In fact, rather than dissect my own solution this week (which in any case differs only in minor details from Bill’s), I would like to present a breakdown of the solution given by Bill, as follows:

More…