1、首先開啟需要編輯的Excel表格,進入到表格的首頁中。
3、然後在開啟的VB程式碼編輯視窗中插入一個新模組,將以下程式碼複製到模組中,點選執行Sub Button()Dim MySht As Worksheet, MyButton As Button, ShtName As StringShtName = "目錄""如果不是目錄,則改為其他名稱For Each MySht In WorksheetsWith MyShtIf .Name ShtName Then.Shapes(ShtName).Delete "Set MyButton = .Buttons.Add(50, 10, 60, 30)With MyButton.Name = ShtName "對按鈕命名.Characters.Text = "返回" & ShtName "指定按鈕的標題.OnAction = "backto" "指定按鈕對應的宏命令End WithEnd IfEnd WithNextSet MyButton = NothingEnd SubSub backto()Worksheets("目錄").Activate[a1].SelectEnd Sub4、然後回到表格編輯頁面中,在其他工作簿中點選“目錄”就會自動返回首頁了。
1、首先開啟需要編輯的Excel表格,進入到表格的首頁中。
3、然後在開啟的VB程式碼編輯視窗中插入一個新模組,將以下程式碼複製到模組中,點選執行Sub Button()Dim MySht As Worksheet, MyButton As Button, ShtName As StringShtName = "目錄""如果不是目錄,則改為其他名稱For Each MySht In WorksheetsWith MyShtIf .Name ShtName Then.Shapes(ShtName).Delete "Set MyButton = .Buttons.Add(50, 10, 60, 30)With MyButton.Name = ShtName "對按鈕命名.Characters.Text = "返回" & ShtName "指定按鈕的標題.OnAction = "backto" "指定按鈕對應的宏命令End WithEnd IfEnd WithNextSet MyButton = NothingEnd SubSub backto()Worksheets("目錄").Activate[a1].SelectEnd Sub4、然後回到表格編輯頁面中,在其他工作簿中點選“目錄”就會自動返回首頁了。