Excel Sheet排序

Sub Sort_Sheets()
  Dim sCount As Integer, I As Integer, R As Integer
  ReDim Na(0) As String
  sCount = Sheets.Count
  For I = 1 To sCount
      ReDim Preserve Na(I) As String
      Na(I) = Sheets(I).Name
  Next
  For I = 1 To sCount - 1
      For R = I + 1 To sCount
          If Na(R) < Na(I) Then
             JH = Na(I)
             Na(I) = Na(R)
             Na(R) = JH
          End If
      Next
  Next
  For I = 1 To sCount
      Sheets(Na(I)).Move After:=Sheets(I)
  Next
End Sub
posted @ 2021-04-26 10:20  叨叨勋  阅读(404)  评论(0编辑  收藏  举报