跳到主要內容

如何基於Excel中的單元格值重命名工作表?

重命名工作表通常在我們的Excel工作中應用,但是您是否曾經嘗試過根據單元格值重命名工作表? 當然,您可以手動重命名工作表,但是在本教程中,我們將介紹一些技巧,這些技巧可以根據單元格值快速重命名多個工作表,從而節省您的工作時間。

使用VBA根據特定單元重命名工作表

使用重命名多個工作表來基於特定單元格重命名工作表 好主意3

使用重命名多個工作表根據一系列單元格內容重命名工作表 好主意3


使用下面的VBA,您可以基於特定單元格重命名相對工作表。

1.選擇要基於其重命名工作表的單元格,在這種情況下,選擇單元格A1。 看截圖:

doc重命名工作表1

2。 按 Alt + F11鍵 打開鑰匙 Microsoft Visual Basic for Applications 窗口。

3。 點擊 插入 > 模塊,然後將以下VBA代碼粘貼到新 模塊 窗口。

VBA:根據特定的單元格值重命名工作表。

Sub RenameSheet()
'UpdatebyKutools20191129
Dim xWs As Worksheet
Dim xRngAddress As String
Dim xName As String
Dim xSSh As Worksheet
Dim xInt As Integer
xRngAddress = Application.ActiveCell.Address
On Error Resume Next
Application.ScreenUpdating = False
For Each xWs In Application.ActiveWorkbook.Sheets
    xName = xWs.Range(xRngAddress).Value
    If xName <> "" Then
        xInt = 0
        Set xSSh = Nothing
        Set xSSh = Worksheets(xName)
        While Not (xSSh Is Nothing)
            Set xSSh = Nothing
            Set xSSh = Worksheets(xName & "(" & xInt & ")")
            xInt = xInt + 1
        Wend
        If xInt = 0 Then
            xWs.Name = xName
        Else
            If xWs.Name <> xName Then
                xWs.Name = xName & "(" & xInt & ")"
            End If
        End If
    End If
Next
Application.ScreenUpdating = True
End Sub

4。 按 F5 運行VBA代碼的鍵。 然後,所有工作表已按每個相對的A1單元格值重命名。

doc重命名工作表2


如果你有 Excel的Kutools,則無需保存VBA代碼,可以使用 重命名多個工作表 功能可以根據所有工作表的相對單元快速重命名。

Excel的Kutools, 與以上 300 方便的功能,使您的工作更加輕鬆。 

免費安裝 Kutools for Excel,請執行以下操作:

1.啟用要重命名其工作表名稱的工作簿。

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

doc重命名工作表11

3.然後在彈出的對話框中,選中要重命名的工作表 工作表 窗格,然後選擇其中之一 重命名選項 您需要,在這裡我將替換工作表名稱,然後檢查 重命名具有特定單元格的工作表,然後選擇您要重命名的單元格。 看截圖:

doc重命名工作表9

4。 點擊 Ok。 現在,工作表已使用特定的單元格內容重命名。

doc重命名工作表2

但是有時候,您需要根據一系列單元格值重命名多個工作表,如下圖所示,在這種情況下,您可以選擇 下面的方法.

doc重命名工作表3


這款獨特的敏感免洗唇膜採用 Moisture WrapTM 技術和 Berry Mix ComplexTM 成分, 重命名多個工作表 of Excel的Kutools,您還可以根據所選範圍重命名工作表。

免費安裝 Kutools for Excel,請執行以下操作:

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

doc重命名工作表11

2。 在裡面 重命名多個工作表 對話框中,您需要指定以下設置:

(1)選擇需要從中重命名的工作表 工作表清單;

(2)檢查 從特定範圍 選項,然後選擇您需要基於其重命名的單元格值;

(3)指定 重命名選項,你可以檢查 在原始工作表名稱之前插入, 在原始工作表名稱後插入, 或者 替換原始工作表名稱,您可以在對話框中預覽相應的結果。

doc重命名工作表10

3。 點擊 Ok,然後您可以看到所選的所有工作表已根據指定的單元格值進行了重命名。

替換原始工作表名稱

doc重命名工作表6

在原始工作表名稱之前插入

doc重命名工作表7

在原始工作表名稱後插入

doc重命名工作表8

使用“重命名工作表”實用程序,您還可以使用特定的前綴或後綴來重命名工作表。 單擊此處以了解有關重命名多個工作表的更多信息。

最佳辦公生產力工具

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

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

產品描述


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

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Every time I look for a VBA routine and find an article like this from you guys, I try the sample code and it NEVER works. It always goes into Debug on the first try. I am starting to believe you deliberately publish poorly written code to drive people to try and purchase your Add-in.
This comment was minimized by the moderator on the site
Hi, Don, the VBA has updated twice, it may be works for most of conditions, but not for the all. 
This comment was minimized by the moderator on the site
In the VBA code example, what changes would be made to select A2 as the cell value rather than A1?
This comment was minimized by the moderator on the site
Hi, Henry, select A2 instead of A1, all sheets will renamed with the value of cell A2.
This comment was minimized by the moderator on the site
'Updateby20150602
This code showing error..............Only works ActiveSheet & RunTime Error 1004 [Object_Worksheet faild]
This comment was minimized by the moderator on the site
Hi, Biplab Das, maybe the original code cannot work at new versions (2013 or later), I have upadated a new code in the tutorial, you could try again.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations