Sub ml()
Dim sht As Worksheet, k&
[a:a] = ""
'清空A列数据
[a1] = "目录"
k = 1
For Each sht In Worksheets
'遍历工作簿中每个工作表
k = k + 1
'累加K值
Cells(k, 1) = sht.Name
'将工作表名称依次放入表格A列
Next
End Sub
Sub sortsheet()
Dim sht As Worksheet, shtname$, i&
Set sht = ActiveSheet
'设置变量sht为当前激活的工作表,即目录表。
For i = 2 To sht.Cells(Rows.Count, 1).End(3).Row
'遍历工作表A列的数据,A1以外。
shtname = sht.Cells(i, 1)
'将A列值赋值为字符串变量shtname
Sheets(shtname).Move after:=Sheets(i- 1)
'将工作表依次移动
Next
sht.Activate
'重新激活目录表
End Sub