View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jindon[_51_] jindon[_51_] is offline
external usenet poster
 
Posts: 1
Default Determining if data is sorted in descending order


Not sure if I understand correctly...

Code
-------------------

Private Sub CommandButton1_Click()
Dim a, i As long, myRange
Set myRange = Range("a1:a100")
If vbYes = MsgBox("Sort Descending Order?",vbYesNo) Then
With myRange
a = .Value
.Sort key1:= .Cells(1,1), order1:= xlDescending, header:= xlNo
For i = 1 To .Rows.Count
If .Cells(i,1) < a(i, 1) Then
MsgBox "Not Sorted in Descengind Order"
.Value = a
Exit Sub
End If
Next
End With
End If
MsgBox "Sorted successfully"
End Su
-------------------

--
jindo
-----------------------------------------------------------------------
jindon's Profile: http://www.excelforum.com/member.php...fo&userid=1313
View this thread: http://www.excelforum.com/showthread.php?threadid=55070