|
すでにichinoseさんからコードの提示があるけど書いてきたので。
Sub main()
Dim tb() As String, Ws As Worksheet, i As Long, ii As Long
Dim Sav As String
AcShNm = ActiveSheet.Name
ReDim tb(1 To 2, 1 To ActiveWindow.SelectedSheets.Count)
Application.ScreenUpdating = False
For Each Ws In ActiveWindow.SelectedSheets
i = i + 1
tb(1, i) = Ws.Index
tb(2, i) = Ws.Name
Next
'昇順バブルソート
For i = 1 To UBound(tb, 2)
For ii = i To UBound(tb, 2)
If tb(2, i) > tb(2, ii) Then
Sav = tb(2, i)
tb(2, i) = tb(2, ii)
tb(2, ii) = Sav
End If
Next
Next
'選択してあるシートを対象に昇順ソート
For i = 1 To UBound(tb, 2)
Sheets(tb(2, i)).Move after:=Sheets(Int(tb(1, i)))
Next
'選択シートしてあったシートを選択状態にする
For i = UBound(tb, 2) To 1 Step -1
Sheets(tb(2, i)).Select 0
Next
Sheets(AcShNm).Activate
Application.ScreenUpdating = False
Erase tb
End Sub
|
|