Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need code to pair off numbers


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
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
Need a fresh pair of eyes ibvalentine Excel Worksheet Functions 11 May 3rd 09 11:33 PM
How can excel generate every unique pair from a set of numbers? mistermat Excel Worksheet Functions 3 August 31st 08 12:52 PM
count and return pair numbers Sly Excel Worksheet Functions 14 July 28th 07 04:51 PM
How do pair different data series. kurt Charts and Charting in Excel 1 June 8th 05 03:10 AM
in excel, how do I find which value doesn't have a pair? curiousjackie Excel Discussion (Misc queries) 3 December 17th 04 05:43 PM


All times are GMT +1. The time now is 09:34 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"