View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Carlos Carlos is offline
external usenet poster
 
Posts: 84
Default combining values ?

Hi,

I think your problem is a bit complicated and has a lot to do with
combinatorics. For example, if you were given 3 letters A, B and C, how much
combinations could you do? The answer is 3x2x1 = 3! = 6. Mainly,
ABC
ACB
BAC
BCA
CAB
CBA

You must think of a bag containing all the characters you need. Then design
a macro that counts how many times have you used that letter. In the example
at hand, two (2 = 3!/3) of the six strings must start with the same letter
(you can only use A twice at the begining of each string). Once you have
started, follow the same logic but with (3-1)! = 2 items. You will also find
useful the concept of recursiveness. For example, the following function
calculates n!, where n is a positive integer.

Public Function f(n As Long)
If n = 0 Then
Call MsgBox("0! is not defined!") 'I'm not sure of this
ElseIf n = 1 Then
f = 1
Else
f = n * f(n - 1)
End If
End Function

--
Carlos


" wrote:

Hello All,

I am not very good with Excel so I hope some of you can share your
ecpertise. What I would like to do, is take a set of values and combine
them where one value per line (the left side) is combined with the
remaining values of the right side in all possible configurations. I'll
try to show an example. Given my values as such:

A vs B
C vs D
E vs F
G vs H
I vs J

I would like to see an output like so:

A D F H
A D F J
A D H J
A F H J

C B F H
C B F J
C B H J
C F H J

E B D H
E B D J
E B H J
E D H J

G B D F
G B D J
G B F J
G D F J

I B D F
I B D H
I B F H
I D F H

I don't have a clue how to do this using Excel but suspect it could be
done? The key thing is I want to combine the left side of a given value
with the right side of the other values. If there were more or less
input values, say it went up to M vs N, I still only want that combined
4 ways like M D F L but still using all the right side values combined
with that left value. If nothing else, is there a formula I can use to
calculate how many outcomes I should end up with given my values? In
the above example, I had 5 different values and ended up with 20
outcomes. What if I had 6 or 7 values?

I hope this makes sense.

Thanks in advance for any help you can provide or points in the right
direction.

jugrnt