同一Excel Sheet排序

右键任意一个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-23 09:38  叨叨勋  阅读(425)  评论(0编辑  收藏  举报