0% found this document useful (0 votes)
343 views3 pages

Bination Permutation (Myrna Larson)

The document contains a code that will generate combinations or permutations of items in a list. The user enters either a C or P in the first cell to indicate combinations or permutations. The number of items in each subset is entered in the second cell. The list of items is entered in subsequent cells. Running the code will output all possible combinations or permutations to a new sheet based on the parameters provided. The code uses a recursive algorithm to efficiently generate the subsets.

Uploaded by

Cristobal Guzman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
343 views3 pages

Bination Permutation (Myrna Larson)

The document contains a code that will generate combinations or permutations of items in a list. The user enters either a C or P in the first cell to indicate combinations or permutations. The number of items in each subset is entered in the second cell. The list of items is entered in subsequent cells. Running the code will output all possible combinations or permutations to a new sheet based on the parameters provided. The code uses a recursive algorithm to efficiently generate the subsets.

Uploaded by

Cristobal Guzman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 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" <[email protected]> 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" <[email protected]> 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