Hi,
I need a way to sort 20 numbers the are in 1 field into 20 seperate fields or count these numbers and report how many of those numbers are between 01 - 10, 11 - 20, 21 - 30 etc upto 71 - 80. the numbers are seperated by a , 'comma' here is an example of what i want to do:
41, 52, 32, 08, 39, 55, 21, 20, 09, 46, 15, 05, 77, 23, 69, 60, 12, 19, 07, 29
they are the numbers in the cell. i want to have a script to make each number go into its own cell either on the same row or in another sheet on the same row, or count the numbers that are in that cell and report how many of each number between a set of numberrs.
so the ouput for this line of numbers should be:
01 - 10 : 4
11 - 20 : 4
21 - 30 : 3
31 - 40 : 2
41 - 50 : 2
51 - 60 : 3
61 - 70 : 1
71 - 80 : 1
or to put each seperate number in a different cell without commas.
thanks Anthony
by: ZwiekhorstPosted on 2004-12-20 at 23:54:50ID: 12873822
Hi Anthony,
this does what you want it will take you number range in cell B1 and put the result into B3 to B10
you just have to put in the A column the "0-10" etc..
Sub numbercontr()
Dim numbers(100), k(8) As Integer
Dim i As Integer
Range("B1").Select
i = 0
For j = 1 To 100 Step 4
numbers(i) = Val(Mid(ActiveCell.Text, j, 2))
i = i + 1
Next
i = 0
While numbers(i) > 0
If (numbers(i) < 11) Then k(1) = k(1) + 1 Else: _
If numbers(i) < 21 Then k(2) = k(2) + 1 Else: _
If numbers(i) < 31 Then k(3) = k(3) + 1 Else: _
If numbers(i) < 41 Then k(4) = k(4) + 1 Else: _
If numbers(i) < 51 Then k(5) = k(5) + 1 Else: _
If numbers(i) < 61 Then k(6) = k(6) + 1 Else: _
If numbers(i) < 71 Then k(7) = k(7) + 1 Else: _
If numbers(i) < 81 Then k(8) = k(8) + 1
i = i + 1
Wend
Range("b3").Select
For i = 1 To 8
ActiveCell(i, 1) = k(i)
Next
End Sub
If you need more help for a full macro let me now
cheers Eric