LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default All combinations

Hi, all
I want to return all possible combinations using the numbers of a specified
range.
For example, if I specify a certain range, whose value is {1,2;3,4}, and
input 2, the hopeful result is {1,2;1,3;1,4;2,3;2,4;3,4}.
What I want is sub procedure with two arguments(range, number of selection).

I know how can do this only if the number of selection is fixed.

Sub AllCombi()
Dim rngX As Range
Dim intX As Integer
Dim intY As Integer
Dim intZ As Integer
Dim intA As Integer
Set rngX = Application.InputBox("Specify the range", Type:=8)
intX = rngX.Cells.Count
intA = 1
For intY = 1 To intX - 1
For intZ = intY + 1 To intX
Cells(intA, 1) = intY
Cells(intA, 2) = intZ
intA = intA + 1
Next intZ
Next intY
End Sub

When the number of looping sentence is a variable, how can I solve it?
That's the point.

Any advice would be much appreciated.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF, AND combinations [email protected] Excel Worksheet Functions 2 May 23rd 09 03:43 PM
Combinations Balaji Excel Worksheet Functions 5 October 28th 07 03:22 PM
Combinations Chris_t_2k5 Excel Discussion (Misc queries) 2 February 7th 06 10:36 AM
Possible Combinations Please HELP!!! Excel Discussion (Misc queries) 1 January 6th 06 03:58 PM
Combinations osprey Excel Worksheet Functions 1 June 11th 05 02:32 AM


All times are GMT +1. The time now is 10:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"