跳到主要內容

如何使工作表標籤名稱等於Excel中的單元格值?

在某些情況下,您可能需要根據指定的單元格值重命名工作表。 在本文中,我們將向您展示使表格選項卡名稱等於Excel中單元格值的方法。

使用VBA代碼使工作表標籤名稱等於單元格值
使用Kutools for Excel使工作表選項卡名稱等於單元格值


使用VBA代碼使工作表標籤名稱等於單元格值

使用以下VBA代碼,可以使工作表標籤名稱自動等於單元格值。

1.右鍵單擊要使工作表名稱等於單元格值的工作表選項卡,然後單擊 查看代碼 從右鍵單擊菜單中。 看截圖:

2.複製下面的代碼並將其粘貼到“代碼”窗口中,然後按 其他 + Q 同時按下兩個鍵以關閉“ Microsoft Visual Basic for Applications”窗口。

VBA代碼:使工作表標籤等於單元格值

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20230130
    On Error Resume Next
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        ActiveSheet.Name = ActiveSheet.Range("A1")
    ElseIf Not Intersect(Target.Dependents, Range("A1")) Then
        ActiveSheet.Name = ActiveSheet.Range("A1")
    End If
End Sub

備註:在代碼中,A1是包含您需要用作工作表名稱的值的單元格。 您可以根據需要進行更改。

從現在開始,當單元格A1中的值更改時,工作表標籤名稱也將同樣更改。


使用Kutools for Excel使工作表選項卡名稱等於單元格值

在本節中,我們向您介紹 重命名多個工作表 的效用 Excel的Kutools。 使用此實用程序,您可以輕鬆地在Excel中使用某些單元格的值來重命名工作表。

申請前 Excel的Kutools首先下載並安裝.

1。 點擊 Kutools 加 > 下載學習單 > 重命名多個工作表。 看截圖:

2。 在裡面 重命名多個工作表 對話框,您需要執行以下操作。

1)。 檢查您要重命名的工作表名稱 工作表 框(您可以選擇一張或多張紙)。
2)。 選擇 替換原始工作表名稱 盒子裡 重命名選項 部分。
3)。 如果要使用指定單元格的值重命名一個或多個工作表,請選擇 從特定範圍 選項,然後選擇要基於其重命名工作表的單元格範圍。
4)。 點擊 OK 按鈕。 看截圖:

您可以看到所選工作表立即被指定的範圍值重命名,如下面的屏幕截圖所示。

筆記:

1.您可以使用 篩選 函數可以輕鬆過濾出所需的工作表(如果存在很多工作表)。
2.如果要重命名每個工作表中具有特定單元格值的多個工作表。 例如,sheet1將等於其單元格A1的值,並且sheet2也將等於其單元格A1的值。 請在 工作表 框,然後選擇 重命名具有特定單元格的工作表 選項,然後在框中指定單元格A1。

3.表格名稱不會隨著單元格值的更改而自動更改。

  如果您想免費試用(30天)此實用程序, 請點擊下載,然後按照上述步驟進行操作。


使用Kutools for Excel使工作表選項卡名稱等於單元格值

最佳辦公生產力工具

熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

kte選項卡201905


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (30)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Good
It was the same thing I was looking for. But now I have a question:
After these steps were done, I created several sheets, I locked the sheet, but when I lock the book and enter a value in the cell, the name of the sheet does not change. In other words, it only changes with the spreadsheet unlocked and I would like to keep the spreadsheet locked
This comment was minimized by the moderator on the site
Boas
Era mesmo isto que estava a procurar. Mas agora tenho uma questão:
Após esses passos feitos, criei várias sheet, bloqueei a folha, mas quando bloqueio o livro e digito um valor na célula, o nome da sheet não muda. Ou seja, só muda com a sheet desbloqueada e gostaria de manter a sheet bloqueada
This comment was minimized by the moderator on the site
bonjour,
que voulez-vous dire par appuyer autre autre+q dans le code vba après avoir collé.
J'ai simplement fermé la page après avoir collé et ça ne marche pas
merci
This comment was minimized by the moderator on the site
worked beautifully!
This comment was minimized by the moderator on the site
Hi Crystal,

When i paste in your code it comes back with error "user-defined type not defined"?

Thanks.
This comment was minimized by the moderator on the site
Hi Tom J,
Make sure these three options are checked in the References - VBAProject dialog box.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/error.png
This comment was minimized by the moderator on the site
This worked perfectly for my first worksheet, but not for the second or third etc (I have up to about 20 worksheets that all need this function). Am I missing something?
This comment was minimized by the moderator on the site
Hi A Owen,
This code only works for one worksheet per time. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
What is the highest nr of worksheets, that can be changed names via Kutools Plus? because the excel letting me only 17 names to changes, and that's it
This comment was minimized by the moderator on the site
I'm using your exact code from the above for VBA code which works perfectly for what I need. However, I have a bunch of macros on a sheet called Job Template that gets copied and reused for every new job. I designed all my macros based on a new copied version called Job Template (2). Once the sheet name is changed to the new job name, the macros no longer work and have to manually do it. I would like to be able to use any of my Macro buttons at any point instead of only using them before I change the sheet name.

Is there a way for the VBA code to always refer to the sheet name before running the rest of the code functions?
This comment was minimized by the moderator on the site
How can I reference two cells. for example name and id number?
This comment was minimized by the moderator on the site
This is exactly what I need, but I need the tab to recreate a date and it isn't working... I assume this is something to do with the way excel works out date and time, can anyone suggest a workaround?
This comment was minimized by the moderator on the site
Hi Nick,
Excel does not support typing the sheet name containing special characters. If the date you type contains the character /, it won't allow you to create the sheet name with that date.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations