Public sub addButton()
Dim i As Integer
Dim n As Integer
Dim SheetName as String
n = ActiveWorkbook.Sheets.Count
For i = 1 To n
SheetName =ActiveWorkbook.Sheets(i).Name
if SheetName <> "主页界面" then
Call Worksheets(SheetName ).OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False , DisplayAsIcon:=False, Left:=108.75, Top:=1.5, Width:=110.25, Height _
:=40.5)
end if
Next
End sub
然后在每一页里面加上以下语句
Private Sub CommandButton1_Click()
Worksheets("主页界面").Activate
End Sub
在没页加个按钮,按钮代码:
Private Sub CommandButton1_Click()
Worksheets("主页界面").Activate
End Sub