Combinations Of Arrays Using Vba

Apr 16, 2009

I need to find the possible combinations for several arrays consisting of binary data. I shall give a simplified example with three arrays and four fields. Lets assume the three starting arrays look as follows:

1 0 0 0
1 0 0 0
1 0 0 0

Each row may contain one field = "1" and all other fields = "0". So the next possible combinations may be:

1 0 0 0
1 0 0 0
0 1 0 0

1 0 0 0
1 0 0 0
0 0 1 0

etc...until:

0 0 0 1
0 0 0 1
0 0 0 1

Assuming k = number of fields and c = number of arrays the possible combinations are k ^ c = 4 ^ 3 = 64. I am looking for vba coding that allows to cycle through all possible combinations and displays them in an excel spreadsheet. Ideally, the code should work for any k and c. Could anyone please give me any pointers as to how to tackle this problem?

p.s. in essence I'm looking for the tabular representation of a tree plan with four branches to commence with, a total of 16 decision nodes, and two possible outcomes (1 and 0)

View 9 Replies


ADVERTISEMENT

Use VBA To Determine Combinations Of Arrays

Feb 27, 2012

I have 5 arrays, each containing 5 elements and want to determine all the combinations.

1 2 4 8 16
1 2 4 8 16
1 2 4 8 16
1 2 4 8 16
1 2 4 8 16

So, for example, we would start with the first element of the first line and work our way down through each subsequent line on the first column and wind up with combinations as follows:

1, 1, 1, 1, 1
2, 1, 1, 1, 1
4, 1, 1, 1, 1
8, 1, 1, 1, 1
16, 1, 1, 1, 1

Then, go down the second column starting with elements from the first array row:

1, 2, 1, 1, 1
2, 2, 1, 1, 1
4, 2, 1, 1, 1
8, 2, 1, 1, 1
16, 2, 1, 1, 1

In all, there will be 5^5 = 3125 possible combinations.

In addition, some elements in each of the 5 array rows may have a value of 0 instead of what is shown above. So, for example, the rows may appear as:

1, 2, 4, 0, 16
0, 2, 0, 8, 0
1, 0, 4, 8, 0
0, 2, 0, 0, 0
0, 0, 0, 8, 0

So, in essense, the first element in each array row may be either a 0 or 1, the second either a 0 or 2, the third either a 0 or 4, the fourth either a 0 or 8 and the fifth either a 0 or 16. If a zero appears in any of the combinations, I do not want the 0 entry to the list of combinations. So, for example, if a combination gives (from the first column above):

1, 0, 1, 0, 0, then I do not want to include the 0 as one of the combination elements and we would have as some of the possible combinations:

1, 2, 1, 2, 8
2, 2, 1, 2, 8
16, 8, 8, 2, 8....etc., but NOT 16, 8 , 8, 2, 0

either a VBA code or a way to hard-code in a worksheet with how this can be accomplished.

View 9 Replies View Related

Number Combinations :: 25 Random Numbers (5 Digit Combinations)

Dec 15, 2008

I have 25 random numbers and I would like to get a possible 5 digit combinations of these numbers. Can anybody help me with the possible formula?

View 9 Replies View Related

Slicing And Dicing CSV Files - Involves Arrays And Jagged Arrays

May 8, 2013

I am retrieving a CSV file from the net. In this file there are 'x' amount of row data and 7 columns. I only care about the values in the 7th column for each row. I also don't care about the entire first row. A graphical version would be represented something like this, with the values I want colored in orange:

|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|

.
. extending until the end of the data set
.

I've managed to dice this thing into a jagged array by first splitting it using vbLf as a delimiter, and therefore adding those to an array called Lines(). Then I split Lines() up using commas as the delimiter and threw those into a jagged array, let's call it Breadcrumbs()(). I want to throw all the values from Breadcrumbs(i)(6) into an array of its own. Here's my code so far:

Code:
Public Sub CSVparser(file As String)
Dim Lines As Variant
Dim j As Integer
Lines = Split(file, vbLf)
ReDim breadCrumbs(UBound(Lines)) As Variant
For i = 1 to UBound(Lines) - 1
breadCrumbs(i) = Split(Lines(i), ",")
Next i
End Sub

View 1 Replies View Related

Number Combinations :: Between 7 To 15 (6 Digit Combinations)

Jun 30, 2008

What I am looking for is to select between 7 and 15 numbers in total, I want all the possible 6 digit combinations for this.

EG: if I choose 2,9,11,13,15,17&26, it would look something like this

2,9,11,13,15,17
2,9,11,13,15,26
9,11,13,15,17,26
And so on.

If I chose more numbers (10) 1,2,3,4,3,6,7,8,9,10 it would start something like this

1,2,3,4,5,6
1,2,3,4,5,7
1,2,3,4,5,8
1,2,3,4,5,9
1,2,3,4,5,10
And so on.

Please remenber I would like to be able to secelt between 7 and 15 number and be given all the possible combinations.

I would like it to be in one sheet but if that can not be done on as many as it takes.

It would be good if I could just type the required number into A1,B1,C1 and so on and they just gave the combinations required.

View 9 Replies View Related

All Possible Combinations That Sum Up To X

Oct 19, 2007

I have a column of transactions lets say 500 or so, of irregular numbers such as 257,273.80 (not something ou can add up in your head...). I know that of those 500 transactions a handful of them have a sum of lets say 2,877,000.00, which I know. Now I need to find all possible combinations of values in this column that equal a sum I enter.

View 4 Replies View Related

Combinations Using Formula

Dec 14, 2008

I've attached an Excel..Its a small 4X4 matrix with numbers filled inside...Next to the right is a Combinations Column..I want to know how can i use just forumla to optain 4digit combination based on the 4X4 matrix. Rule is only numbers from the 4X4 be used.

View 14 Replies View Related

Combinations That Sum To A Given Total?

Feb 26, 2014

I have up to 30 cells each with an integral value from 1 to 5. The task is to list all the ways that selections of from 1 to 5 cells can be made from the list such that the value of the sum of the selection is 5. It will usually be the case that there will be a final selection that will not sum to 5 and this needs listing also.

I am aware of coding that can list out combinations, but not in a form that can be adapted to deal with the summing limitation. I hope that I will be able to code so that I can deal with different numbers of cells and different sum values.

View 1 Replies View Related

Median Of All Combinations

Jul 25, 2008

I have 5 numbers (can be with decimals) in column A (A1:A5). For these
numbers, I want all combinations as well as the median of these
combinations.

I'm pretty far already. However, the median seems to be calculated
wrong.

View 12 Replies View Related

Find Possible Combinations

Feb 11, 2009

I need to find possible combinations for the following example:

a*x + b*y + c*z = t
p = 10

Where
a = 0
b = 5
c = 10
t = 30

x + y + z has to = p

a, b, c, t, and p would be variables that I would specify. The numbers above are just examples. What I would need to see as output would be:

7a, 0b, 3c
4a, 6b, 0c
5a, 4b, 1c
etc...

View 8 Replies View Related

Macro That Gives All The Sum Combinations

Nov 14, 2013

I have a table with 3 columns and n number of rows looking like this:
A1 A2 A3
B1 B2 B3
C1 C2 C3
D1 D2 D3
...

I need to create a macro that gives all the sum combinations like this:
A1+B1+C1+D1
A1+B1+C1+D2
A1+B1+C1+D3
A1+B1+C2+D1
A1+B1+C2+D2
A1+B1+C2+D3
A1+B1+C3+D1
A1+B1+C3+D2
A1+B1+C3+D3
A1+B2+C1+D1
A1+B2+C1+D2
A1+B2+C1+D3
...

View 1 Replies View Related

Find All Possible Combinations Below Certain Value?

Feb 3, 2014

I have a simple list of names with associated numerical values.

I would like to create a formula that will produce a series of all possible series of 8 of those names whose combined numerical values are at or below a certain threshold (or between two thresholds, if that's easy). Bonus points if the total combined value for each group is easily shown, but that'd just be gravy.

View 9 Replies View Related

How To Calculate Combinations ?

Nov 12, 2005

I want to see how much combinations are possible when i got 6 numbers..

-- got this numbers 1--2--3--4--5--6
-- want to calculate how much combinations of ( 2 ) numbers possible
-- want to calculate how much of ( 3 ) numbers possible
-- want to calculate how much of ( 4 ) numbers possible
-- want to calculate how much of ( 5) numbers possible

-- never 2 same numbers together (2-2) or (2-2-3) or (2-2-3-4) may not be in list

-- How can i make the result visible in kind of list ?


I would be nice if somebody knows a good solution..

View 9 Replies View Related

Figure Out The Combinations Available

Apr 27, 2007

i'm doing a process and in column N, i would need to have the following combinations:

A1
A2
C1
C2
H1
I1

so basically, a formula that would figure out the combinations available!
can this be done using a formula?

******** ******************** ************************************************************************>Microsoft Excel - Cost Calculator---V5---Try.xls___Running: 11.0 : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutK39=
KLMN39A12 40B 41C12 42D 43E 44F 45G 46H11 47I11 48J Cost Calculator
[HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

View 9 Replies View Related

Display The Combinations

Jun 19, 2007

I have a list of numbers from 1 to 20 form a2 to a21, what I would like to do if possible if figure out many combinations of 5 there are for these numbers, and then second if possible display the combinations.

E.g. say there was a total 250000 combinations then show those 250000

View 9 Replies View Related

Given Number Combinations

Mar 16, 2008

I want to have a sheet with all the previous drawings for the florida lottery.
Then I want excel to ask me how many numbers do I wish to play.

Then when I say 12 (for example) it would pick 12 numbers from 1 to 53 and match all possible comibinations of thoses numbers to the the previous drawings and tell me wich 12 number combination would have won more times then others. So it would need to compare each possible 12 nmber combination to each other and see wich one won more 6outof6, 5outof5, 4outof4, and 3outof3. Then give me the one with the highest winings

View 9 Replies View Related

How To Count All Possible Combinations

Oct 24, 2008

I have a table:
VOICEDATAIPADSLCustomer 1YESCustomer 2YESYESCustomer 3YESYESCustomer 4YESYES

And i need to count all possible combinatins. Result could be as:

Custome who use Voice also use combination:1VOICE ADSLCustome who use Data also use combination:1DATAIP2DATAADSLCustome who use IP also use combination:1IPDATACustome who use ADSL also use combination:1ADSLDATA

View 9 Replies View Related

Number Combinations

Oct 28, 2008

Here is what my table kind of looks like

A B
4 0.25
7 0.3
2 0.1
3 0.15


4 0.30
1 0.4
8 0.05
2 0.1

Now there is the number and the number(A) that it value it represents (B). This is what I want. I want to see all possible number combinations between the upper and lower A columns listed veritcally under the whole set, with out duplicating any numbers and with the upper numbers only being in the 1st position and the lower numbers being in the second position Ex( 4-1, 4-8, 4-2, 7-4, 7-1, ect, ect (listed vertically). Now in column B under, right beside each possible combination I want to see the result of the two values multiplied (ex. beside 4-1 I would like to see 0.1)

So below that mess listed above I want to see something like this

A B
4-1 0.1
4-8 0.0125
ect
ect
ect

I want to be able to swith the values around and have it automatically make the correction.

View 9 Replies View Related

Creating All Possible Combinations

Nov 24, 2008

I am trying to create a combination list. I have 48 items and I want to create all possible comibinations of 3 items from this group of 48 items.

I did something similar to create all possible combinations of 2 items from the group of 48 items in the attached spreadsheet. This was done manually and was time consumning. I want to do something similar for all possible combinations of 3 items from this group of 48 items.

All my 48 items are listed in rows 4 and 5. I want to enter the number "1" in each column to indicate my selection. Right now I have 2 ones per row. But I want to do 3 ones per row.

View 9 Replies View Related

Permutation/Combinations

Aug 3, 2009

Can this be done in Excel? Using the digits 0,1,2,3,4,5,6,7,8,9 create all the permutations/combinations with limits on some of the digits. The digits 0,7,8,9 can only be used a max of 3 times in any one permutation/combination, digits 2,3,4,5,6 can only be used 4 time in any one permutaion/combination, producing a 5-digit string.
Example of expected results.
0 1 0 2 7

View 9 Replies View Related

Combinations - Win Or Draw

Nov 28, 2009

I'm creating a spreadsheet regarding football teams and want to lis thte combinations of results for each team.

Specifically, if the team will win or draw.

So, I have 6 teams, each team can either win or draw.

I want to display the combinations of team 1 winning AND team 2 winning AND team 3 winning etc.

View 9 Replies View Related

Key Show All Of The Possible Combinations

Dec 23, 2009

Outside the door of my flat I have a key holder – which has a combination of 4 digits. No-one knows what the combination is, so I’d like to try to find it, clear it and use it.
I wondered if there was a way to use excel to show all of the possible combinations so I can then tick them off as I try them…?

The possible numbers are 0-9, but you cant press a button more than once in any given attempt… so… first possible combination would be 0123… not 0001.

View 9 Replies View Related

Block Alt Key And All Combinations With It Except

Jan 23, 2010

This supposed to block Alt key and all combinations with it except Alt+F1, Alt+Tab and Alt+Shift. But what I get is: if I press Alt+F1 only, F1 is triggered.

Private Function LowLevelKeyboardProc(ByVal nCode As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Static kbdllhs As KBDLLHOOKSTRUCT

If nCode = HC_ACTION Then
Call CopyMemory(kbdllhs, ByVal lParam, Len(kbdllhs))
If CBool(kbdllhs.flags And LLKHF_ALTDOWN) Then
Select Case kbdllhs.vkCode
Case vbKeyF1, VK_LSHIFT, VK_TAB
Case Else
LowLevelKeyboardProc = 1
Exit Function
End Select
End If
End If
LowLevelKeyboardProc = CallNextHookEx(m_hDllKbdHook, nCode, wParam, lParam)
End Function

View 9 Replies View Related

All Possible Combinations From Groups

Nov 11, 2009

I have a set of 13 groups, each with anywhere from 1-9 different variables for a total of 56 variables. I want to find all the possible combinations of 1-5 variables. Only one variable can be used from each group in a combination. Please see attached data sheet.

View 5 Replies View Related

Chart All Possible Combinations

Dec 10, 2009

I have 4 groups of 5 variables each. I need to know how to make a chart in excel that lists out all of the possible 4 variable combinations of each.

Example: The groups are Group A, grp B, Grp C, Grp D and each group has 5 variables. You can use one variable from each group for a combination.

View 5 Replies View Related

Combinations (not Permutations)

Apr 26, 2006

You will find a VBA Code for a PRIVATE example - displaying all 6 numbers combinations out of 10 (1-10).

My code displays them (in column "A") BUT What my question to you is - does someone have a General/Universal code to handle other kinds of combinations.

To my opinion, the usage of Nested (For-Next) Loops will not be the ideal solution - so maybe by using VBA Recursion ?

View 3 Replies View Related

Combinations Which Are Exclusive Of Each Other

Jun 7, 2006

in columns CT, CU, and CV i have listed all possible combinations of 3 produced from the 12 variables (a through l). each combination has a score (listed in column cw). I have sorted all combinations in descending order by score. is there a way I can search all the combinations and select the 4 which have the highest score but are also exclusive? that is, none of the 4 combinations may contain the same variables.

View 5 Replies View Related

Generate All Possible Combinations

Dec 28, 2006

Is there an Excel Addin that will let me figure out the total number of combinations for any size number pool I specify (39,49, 53) and with any combination quantity I specify (3, 4, 5, 6)? And most important is that all these combinations be displayed in a column separated by commas.

Is a VBA script designed to handle something this complex.

View 9 Replies View Related

Combinations From Set Of Numbers

Jan 4, 2007

I want to do all columns combination that is (C=4^N/(3*N+1); N=4) for numbers 1,2,3,4.

as like this,

1111....2222....3333.....4444.....
1111....2222....3333.....4444.....
1111....2222....3333.....4444.....
1234....1234....1234.....1234....

View 9 Replies View Related

All Combinations/Permutations

Jun 2, 2007

I must first thank the forums for the amazing help in making my life just a little easier, especially member "shg" for helping set up the VBA code to help me.

So I have a sheet to develop all possible combinations of units, the letters with their associated values above, as well as the maximum number of units possible. The user inputs a top value, this is followed by some subtraction leading to a working value with a tolerance level in which the sum of the combinations needs to remain within.

What my predicament is that while the VBA code in the attached book works to develop most combinations, when I input a small number such as 405, the combinations that arise are not complete. The results are shown in the attached workbook: show combinations of H and PP, but any human can read that there should also be 2 HN in the results, as the math add's up to within the tolerance level.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved