Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have been grappling with an idea of setting off pairs (even clusters) of numbers *using code *as in (1,2,3); (4,5,6); (7,8,9) ... (58,59,60) for a data range 1-60 in this case. This is easily accomplished on worksheet but I need results that can be stored in, and retrieved from an array. In the generalized case, I would want the code to trussle up n elements, where n can be any number not more than the count of elements in the data range population set. Thus, in the current instance, the code should be adaptable to draw out (1,2);(3,4);(5,6)... where n=2 as well as (1,2,3,4,5), (6,7,8,9,10) ... where n=5. The attempted code below further illustrates what I am groping for. Sub Cluster3Elements() Dim arr() n = 0 For i = 1 To 60 Step 3 ReDim Preserve arr(n) arr(i) = i & "," & i + 1 & "," & i + 2 === Subscript Out of range error n = n + 1 Next 'test For j = LBound(arr) To UBound(arr) Debug.Print arr(j) Next End Sub TIA. Davidm -- davidm ------------------------------------------------------------------------ davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645 View this thread: http://www.excelforum.com/showthread...hreadid=513059 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need a fresh pair of eyes | Excel Worksheet Functions | |||
How can excel generate every unique pair from a set of numbers? | Excel Worksheet Functions | |||
count and return pair numbers | Excel Worksheet Functions | |||
How do pair different data series. | Charts and Charting in Excel | |||
in excel, how do I find which value doesn't have a pair? | Excel Discussion (Misc queries) |