zoom38
03-27-2007, 02:14 PM
I have a sub with 10 variables. I can put the values on the worksheet and then sort them but I would like to be able to sort the variables in code without putting the values on the worksheet. I have been researching it and it appears I have to build and array. I don't have any experience with arrays nor do I understand them. Can some one please assist me.
Sub ColumnY()
Dim LastRow As Long
Dim First As Long
Dim Second As Long
Dim Third As Long
Dim Fourth As Long
Dim Fifth As Long
Dim Sixth As Long
Dim Seventh As Long
Dim Eighth As Long
Dim Ninth As Long
Dim None As Long
Dim LR As Long
Dim r As Long
'Find The Last Used Cell In Column O
LastRow = Cells(Rows.Count, 15).End(xlUp).Row
r = 3
Do
If Cells(r, 15).Value = "1st" Then
First = First + 1
End If
If Cells(r, 15).Value = "2nd" Then
Second = Second + 1
End If
If Cells(r, 15) = "3rd" Then
Third = Third + 1
End If
If Cells(r, 15).Value = "4th" Then
Fourth = Fourth + 1
End If
If Cells(r, 15).Value = "5th" Then
Fifth = Fifth + 1
End If
If Cells(r, 15).Value = "6th" Then
Sixth = Sixth + 1
End If
If Cells(r, 15).Value = "7th" Then
Seventh = Seventh + 1
End If
If Cells(r, 15).Value = "8th" Then
Eighth = Eighth + 1
End If
If Cells(r, 15).Value = "9th" Then
Ninth = Ninth + 1
End If
If Cells(r, 15).Value = "None" Then
None = None + 1
End If
r = r + 1
Loop While r <= LastRow
End Sub
Thanks
Gary
Sub ColumnY()
Dim LastRow As Long
Dim First As Long
Dim Second As Long
Dim Third As Long
Dim Fourth As Long
Dim Fifth As Long
Dim Sixth As Long
Dim Seventh As Long
Dim Eighth As Long
Dim Ninth As Long
Dim None As Long
Dim LR As Long
Dim r As Long
'Find The Last Used Cell In Column O
LastRow = Cells(Rows.Count, 15).End(xlUp).Row
r = 3
Do
If Cells(r, 15).Value = "1st" Then
First = First + 1
End If
If Cells(r, 15).Value = "2nd" Then
Second = Second + 1
End If
If Cells(r, 15) = "3rd" Then
Third = Third + 1
End If
If Cells(r, 15).Value = "4th" Then
Fourth = Fourth + 1
End If
If Cells(r, 15).Value = "5th" Then
Fifth = Fifth + 1
End If
If Cells(r, 15).Value = "6th" Then
Sixth = Sixth + 1
End If
If Cells(r, 15).Value = "7th" Then
Seventh = Seventh + 1
End If
If Cells(r, 15).Value = "8th" Then
Eighth = Eighth + 1
End If
If Cells(r, 15).Value = "9th" Then
Ninth = Ninth + 1
End If
If Cells(r, 15).Value = "None" Then
None = None + 1
End If
r = r + 1
Loop While r <= LastRow
End Sub
Thanks
Gary