Here is copy of working code:
Sub valueSortTest()
'***SETTING VARIABLES***
Dim readForm As Worksheet, cpt(1 To 10) As String, charges(1 To 10) As Double, fsValue(1 To 10) As Double
Dim MaxSort(1 To 3), x As Integer, sortValue(1 To 3, 1 To 10), iFirst As Integer, iLast As Integer
Dim j As Integer
'***IDENTIFYING WORKSHEET TO BE USED***
Set readForm = ActiveWorkbook.Worksheets("Sheet1")
iFirst = LBound(charges)
iLast = UBound(charges)
'***READING DATA INTO AN ARRAY***
For x = iFirst To iLast
cpt(x) = readForm.Range("A" & x).Value
charges(x) = readForm.Range("B" & x).Value
fsValue(x) = readForm.Range("C" & x).Value
sortValue(1, x) = cpt(x)
sortValue(2, x) = charges(x)
sortValue(3, x) = fsValue(x)
Next x
'***SORTING ARRRAY [FIRST TIME]***
For x = iFirst To iLast - 1
For j = x + 1 To iLast
If sortValue(3, x) < sortValue(3, j) Then
MaxSort(1) = sortValue(1, j)
MaxSort(2) = sortValue(2, j)
MaxSort(3) = sortValue(3, j)
sortValue(1, j) = sortValue(1, x)
sortValue(2, j) = sortValue(2, x)
sortValue(3, j) = sortValue(3, x)
sortValue(1, x) = MaxSort(1)
sortValue(2, x) = MaxSort(2)
sortValue(3, x) = MaxSort(3)
End If
Next j
Next x
'***PLACE SORTED VALUES INTO SPREADSHEET/FORM***
For x = iFirst To iLast
readForm.Range("E" & x).Value = sortValue(1, x)
readForm.Range("F" & x).Value = sortValue(2, x)
readForm.Range("G" & x).Value = sortValue(3, x)
Next x
End Sub
Bookmarks