View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ZuludogM ZuludogM is offline
external usenet poster
 
Posts: 6
Default Sorting each row individually CORRECTION

After sending the post, I caught a math error - Here is the corrected version of the code:


Public Function Yaghanate(Target As Range) As Double

On Error GoTo handleCancel
Application.EnableCancelKey = xlErrorHandler

M = WorksheetFunction.Max(Target)
AfterMax = False
Y = M
D = 0

For i = 1 To Target.Columns.Count
c = Int(Target.Cells(1, i).Value) + 0

If c = M And Not AfterMax Then
AfterMax = True
ElseIf c 0 And Not (WorksheetFunction.IsText(c) Or _
WorksheetFunction.IsError(Target.Cells(1, i).Value)) Then
D = D + WorksheetFunction. _
RoundDown(WorksheetFunction.Log(c), 0) + 1
Y = Y + c / 10 ^ D
End If
Next i
Yaghanate = Y

handleCancel:
If Err 0 Then
CellRef = CVErr(xlErrValue)
End If

End Function