+ Reply to Thread
Results 1 to 2 of 2

Thread: Determining if data is sorted in descending order

  1. #1
    headly
    Guest

    Determining if data is sorted in descending order

    I capture the pre-sorted data to an array, then show a form to ask user to
    sort descending; In the form, user clicks button after sorting and I want to
    compare pre sorted to post sorted values; can't pass the presorted array to
    the buttons click event. Ideas for a workaround? TY

  2. #2
    Valued Forum Contributor
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2010
    Posts
    1,091
    Not sure if I understand correctly...
    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 Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0