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
详细步骤如下:1.插入命令按钮2.会自动d出”宏“界面,选择”新建“3.出现的VBA设计界面,会自动生成两串代码4.在这串代码中间输入要执行的语句5.返回工作表,点击按钮,即执行编写的程序欢迎分享,转载请注明来源:内存溢出
评论列表(0条)