Re: Coding Help (only Ideas)
this may help:
it is code to sort an array it works very fast
so you could dump into the array, pass the arry in and sort it...
then like you said divide the ubound to find the ranges for each percent
VB Code:
Private Sub QuickSort(C() As String, ByVal First As Long, ByVal Last As Long)
Dim Low As Long, High As Long
Dim MidValue As String
Low = First
High = Last
MidValue = C((First + Last) \ 2)
Do
While C(Low) < MidValue
Low = Low + 1
Wend
While C(High) > MidValue
High = High - 1
Wend
If Low <= High Then
Swap C(Low), C(High)
Low = Low + 1
High = High - 1
End If
Loop While Low <= High
If First < High Then QuickSort C, First, High
If Low < Last Then QuickSort C, Low, Last
End Sub
Private Sub Swap(ByRef A As String, ByRef B As String)
Dim T As String
T = A
A = B
B = T
End Sub
Re: Coding Help (only Ideas)
You could do this in Excel in less time than it took to type your question.
Anyway, get your data in an array. Sort the array on the income column, lo to hi.
For however many people you have in the array, N, each band B will be N * .20, or N / 5.
The first B entries in the sorted array are the lowest band. The next B entries are the next band. etc.
Example: N = 155, B = 31
Sorted array = A(i) or A(c,i) for multiple columns.
Band 1 = A(0) thru A(B-1) 'Note that VB defaults to base 0 arrays.
Band 2 = A(B) thru A(B+B-1)
And so on.
Does that help, or do you need to discuss the actual sorting process?