You are on page 1of 3

A, B, C A, B, D A, B, E A, C, B A, C, D A, C, E A, D, B A, D, C A, D, E A, E, B A, E, C A, E, D B, A, C B, A, D B, A, E B, C, A B, C, D B, C, E B, D, A B, D, C B, D, E B, E, A B, E, C B, E, D C, A, B C, A, D C, A, E C, B, A C, B, D C, B, E C, D, A C, D, B C, D, E C, E, A C, E, B C, E, D D, A, B D, A, C D, A, E D, B, A D, B, C D, B, E D, C, A D, C, B D, C, E D, E, A D, E, B D, E, C E, A, B E, A, C E, A, D E, B, A E, B, C E, B, D E, C, A E, C, B E, C, D E, D, A E, D, B E, D, C

P 3
A B C D E

< 1. Enter the letter C or P in A1 (C = combinations, P = permutations) < 2. Enter the number of items involved in A2 < 3. Enter the items in A3 down, e.g.: A, B, C

From: "Tom Ogilvy" <twogi...@msn.com> Subject: Re: Combination/Permutation Generation Date: Thu, 9 Sep 2004 11:34:29 -0400 Newsgroups: microsoft.public.excel.programming

This code by Myrna Larson will do it (read the dire ListPermutations 4. Select A1, then click the button above to run the sub ListPermutations 5. The results will be written to a new sheet (just to the left of this sheet) Option Explicit

Dim vAllItems As Variant Dim Buffer() As String Dim BufferPtr As Long Dim Results As Worksheet ' ' Posted by Myrna Larson ' July 25, 2000 ' Microsoft.Public.Excel.Misc ' Subject: Combin ' ' 'Since you asked, here it is. It is generic, i.e. 'it isn't written specifically for a given population an ' as yours it. It will do permutations or 'combinations. It uses a recursive routine ' to generate the subsets, one routine 'for combinations, a different one for permutations.

'To use it, you put the letter C or P (for combination 'in a cell. The cell below that contains the number o 'The cells below are a list of the items that make up 'They could be numbers, letters and symbols, or wo

'You select the top cell, or the entire range and run 'The subsets are written to a new sheet in the work

y" <twogi...@msn.com> bination/Permutation Generation 2004 11:34:29 -0400 osoft.public.excel.programming

a Larson will do it (read the directions).

here it is. It is generic, i.e. cifically for a given population and set size, l do permutations or uses a recursive routine ubsets, one routine a different one for permutations.

the letter C or P (for combinations or permutations) below that contains the number of items in a subset. re a list of the items that make up the population. mbers, letters and symbols, or words, etc.

p cell, or the entire range and run the sub. written to a new sheet in the workbook.

You might also like