Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / February 2008

Tip: Looking for answers? Try searching our database.

Combinations Repost

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joosy - 06 Feb 2008 09:49 GMT
Rather than reinvent the wheel, can anyone suggest code to create
combinations and permutations based on the number of elements that need to
be combined?

Example

CombIn (1DArray, 2) would output

12
13
21
23
31
32

Signature

Stevie

"Build a man a fire and he will be warm for one night. Set a man on fire,
and he will be warm for the rest of his life."    ~ Sun-Tzu on Fire

Ed Ferrero - 06 Feb 2008 11:37 GMT
Not too sure I understand the question.

Do you want  all combinations of 2-digit integers?
Then count from 0 to 99 and format as 00.

Do you want all combinations of the numbers from 1 to 3?
Then enter 1,2,3 in cells A2, A3, A4 and B1, C1, D1 and
enter in cell B2 the formula =$A2 & B$1 and copy

Like this;
           1                     2              3
1     =$A2&B$1   =$A2&C$1
2     =$A3&B$1
3

Ed Ferrero
www.edferrero.com
Dave D-C - 06 Feb 2008 16:34 GMT
And you can have
 PermutationsWithReplacement
 CombinationsWithoutReplacement
 CombinationsWithReplacement
and limited replacement and ..

Option Explicit

Const N = 3, K = 2
Dim BigSet$(N), Flags%(N)

Sub PermutationsWithoutReplacement()
 BigSet(1) = "1"
 BigSet(2) = "2"
 BigSet(3) = "3"
 Call PWR(N, K, "", 0) ' n, k, str, level
End Sub

Sub PWR(pN%, pK%, pStr$, pLvl%)
 Dim i1%
 If pLvl = pK Then
   Debug.Print pStr
   Exit Sub
 End If
 For i1 = 1 To N
   If Flags(i1) = 0 Then
     Flags(i1) = 1
     Call PWR(N, K, pStr & BigSet(i1), pLvl + 1)
     Flags(i1) = 0
   End If
 Next i1
End Sub

>Rather than reinvent the wheel, can anyone suggest code to create
>combinations and permutations based on the number of elements that need to
[quoted text clipped - 10 lines]
>31
>32
joeu2004 - 06 Feb 2008 19:12 GMT
> Rather than reinvent the wheel, can anyone suggest code to create
> combinations and permutations based on the number of elements
> that need to be combined?

Sure, it's easy.  But my first question is:  why are you interested?
Perhaps the whole purpose is indeed for __you__ to "reinvent the
wheel".  Is this a class assignment?
Joosy - 07 Feb 2008 09:53 GMT
On Feb 6, 1:49 am, "Joosy" <Spam@free> wrote:
> Rather than reinvent the wheel, can anyone suggest code to create
> combinations and permutations based on the number of elements
> that need to be combined?

Sure, it's easy.  But my first question is:  why are you interested?
Perhaps the whole purpose is indeed for __you__ to "reinvent the
wheel".  Is this a class assignment?

You just gave me my first real chuckle of the day and reinforced that you
never know in forums whether you a dealing with a ten year-old whiz kid or a
Nonagenarian.

I'm not quite at the latter yet. This is intended as a parting gesture at
work after thirty-five years. Some will appreciate it. Some will not. Its a
follow up to an Excel (self taught) project completed years ago. Some bright
spark invented some very narrow rules relating to the work processes this
tool helps design. This is intended only as Q&D tool to develop sample sets
that what can be done in a set number of 7-day weeks is finite and that the
constraints are too constrictive. There are only so many combinations that
can be considered.

I haven't been able to focus on Excel or Access for about five years. You
don't know how much VBA develops your thought processes until you suffer
rust and sludge from lack of use. I would once have worked through this as a
self-disciplined learning exercise but, I now have 73 working days remaining
and incredible pressure to pass on a vast array of experience and knowledge
unrelated to programming - before hand over to my replacement who is yet to
arrive can start.

One of life's lessons. You really appreciate how precious time is when you
have a finite amount of time to wrap up all those things you always wanted
to achieve. Could be worse. Might be dying <bg>

Oh! No. It's not a class assignment.

Signature

Stevie

"Build a man a fire and he will be warm for one night. Set a man on fire,
and he will be warm for the rest of his life." ~ Sun-Tzu on Fire

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.