MSFlexgrid countingsort

Dear Experts, I have a MSFlexGrid1 With 5 colums of integer data, max integer is 1 to 50.
I would like to countsort these colums, so that I end up with a list in a second MSFlexgrid2, of the counted and sorted data like the list below. In the second MSFlexgrid2 there should be only two colums as shown below. The code will need to identify the individual numbers from 1 to 50, and show how many times they are repeated in the 5 columns. I am using vb6. Your help would be appreciated, thank you.

Number    Frequency
1              80
2              65
3              45
4              90
etc           etc
50            120
eemit

membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Version 2:

``````Private Sub Command1_Click()

On Error GoTo Err_Handler

Dim c As Long
Dim r As Long

Dim nValue As Long
Dim nCountColumns As Long
Dim aNumers(1 To 50) As Long

nCountColumns = 5

With MSFlexGrid1
nValue = 0

For r = 1 To .Rows - 1
For c = 0 To nCountColumns - 1
If Len(.TextMatrix(r, c)) > 0 Then
If IsNumeric(.TextMatrix(r, c)) Then
nValue = Val(.TextMatrix(r, c))
If (nValue > 0) And (nValue <= 50) Then
aNumers(nValue) = aNumers(nValue) + 1
End If
End If
End If
Next c
Next r
End With

Call FillCountGrid(aNumers(), MSFlexGrid2)

Exit Sub

Err_Handler:
Debug.Print "ERROR (Command1_Click): " & CStr(Err.Number) & ", " & Err.Description

End Sub``````
AWaterfalls

Version 2, Worked very well. Thank you, you get maximum points for that answer.

I've requested that this question be closed as follows:

Accepted answer: 0 points for AWaterfalls's comment #a38731535

for the following reason:

It Just Worked First Tme.
Hi AWaterfalls,
Thank you,
you should accept my answer as solution.
https://www.experts-exchange.com/help/viewHelpPage.jsp?helpPageID=24
Accept: eemit {http:#a38729340}

In her post {http:#a38731535}