Sub Sort_Active_Book()
Dim i As Integer
Dim j As Integer
Dim iAnswer As VbMsgBoxResult
'
' Prompt the user as which direction they wish to
' sort the worksheets.
'
   iAnswer = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) _
     & "Clicking No will sort in Descending Order", _
     vbYesNoCancel + vbQuestion + vbDefaultButton1, "Sort Worksheets")
   For i = 1 To Sheets.Count
      For j = 1 To Sheets.Count - 1
'
' If the answer is Yes, then sort in ascending order.
'
         If iAnswer = vbYes Then
            If UCase$(Sheets(j).Name) > UCase$(Sheets(j + 1).Name) Then
               Sheets(j).Move After:=Sheets(j + 1)
            End If
'
' If the answer is No, then sort in descending order.
'
         ElseIf iAnswer = vbNo Then
            If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name) Then
               Sheets(j).Move After:=Sheets(j + 1)
            End If
         End If
      Next j
   Next i
End Sub
Share
Related Documents
  1. Visual Basic Tutorial 2 (1342)
  2. Visual Basic Tutorial 3 (1373)
  3. VB Script basic & advanced manual for ref (738)
  4. VB Script tutorial for QTP (2258)
  5. QTP VB Script Basic Concepts (2013)
  6. VB Script Interview Question for QTP (7984)
  7. VB Script Fundamentals And Features (1672)
  8. VB Script Example (2322)
  9. QC Connection in QTP through VB script. (3961)
  10. Vb Script (1351)
  11. [Ebook] VBScript Reference Manual (2148)
  12. VB script to automate Outlook (585)
  13. Visual Basic Tutorial 1 (1471)
  14. Vb script in QTP (1398)
  15. Lap trinh VB.NET Vovisoft (1729)
  16. VB script in QTP (1957)
  17. [Ebook] Black Books for Developer and Tester (1525)
  18. Explanation of VBScript for use in HP QuickTest Professional (1321)
  19. Automation testing : Visual Basic Script (1730)
  20. How To Run Selenium Script In Eclipse (5796)