• Sharebar

## Permutations in Excel

I posted an article about Permutations in Excel once before, back in 2005. I actually made a mistake in my example, and was corrected by a reader in a comment- thanks MathBoss.

I have since had another reader, Dam ask a question that I am not sure of the answer of. So I am opening it up to you Excel experts out there.

Here is the question as Dan wrote it.

How in Excel can I create ALL permutations of a given data set. for example, imagine 5 columns. Each column has a differnet (sic) number of unique entries. Column 1 can be A, B. Column 2 could be A, B, C, D, E and so on. I want to combine 1 item of each 5 columns and keep doing it until I create all possible combinations. The number of permutations (PERMUT) may be very large so I need to automate this. I'd like to avoid building a macro since I am sick of building them and I like the static spreadsheet challenge more.

## Dynamic Ranges - and using VBA to create them

Andrew recently posted a piece of VBA code used to create dynamic ranges. Very useful.
Here is my original post on dynamic ranges posted back in 2004 repeated.
If you have used a range name before then you will know that it can be frustrating updating the reference of the range name if you want to add data to the range.
Here are some ways you can dynamically update the range by using the OFFSET function in the range name reference.
Assume for all these examples that column A has a mixture of text and numbers for several cells.
Click Insert - Name - Define on the menu.
In the Names in Workbook Dialog box type a range name (Eg test_range) and then try these different options.
1: Expand Down as Many Rows as There are Numeric Entries.
In the Refers to box type: =OFFSET(\$A\$1,0,0,COUNT(\$A:\$A),1)
2: Expand Down as Many Rows as There are Numeric and Text Entries.
In the Refers to box type: =OFFSET(\$A\$1,0,0,COUNTA(\$A:\$A),1)

## Finding MAX date with an Array Formula in Excel

Last week I was struggling with getting an array formula to work properly with the MAX function.
I had a column of business units, a column of dates and a status column.
I wanted to find the most recent date for any given business unit where the status was a particular criteria.
I did try using Bob Phillip's sum product page and Chris Pearson's array formulas page, but it still wasn't working right. Fortunately Bob emailed me with the answer and explained it very well. (I was missing the IF function).
Heres the formula and what Bob said about it:
=MAX(IF((criteria_range1="criteria1")* (criteria_range2="criteria2")* (criteria_range3="criteria3"), date_range))

## NPV and FV From Scheduled Cash Flows

When readers ask questions that I think others would find useful, I try to take the time to frame my answer as an article.