跳到主要内容

如何使工作表标签名称等于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 使工作表选项卡名称等于单元格值

在本节中,我们向您介绍 重命名多个工作表 实用程序 Kutools for Excel。 使用此实用程序,您可以轻松地在Excel中使用某些单元格的值来重命名工作表。

申请前 Kutools for Excel首先下载并安装.

1。 点击 Kutools 加 > 工作表 > 重命名多个工作表。 看截图:

2.在 重命名多个工作表 对话框,您需要执行以下操作。

1)。 检查您要重命名的工作表名称 工作表 框(您可以选择一张或多张纸)。
2)。 选择 替换原始工作表名称 重命名选项 部分。
3)。 如果要使用指定单元格的值重命名一个或多个工作表,请选择 从特定范围 选项,然后选择要基于其重命名工作表的单元格范围。
4)。 点击 OK 按钮。 看截图:

您可以看到所选工作表立即被指定的范围值重命名,如下面的屏幕截图所示。

:

1.您可以使用 筛选器 函数可以轻松过滤出所需的工作表(如果存在很多工作表)。
2.如果要重命名每个工作表中具有特定单元格值的多个工作表。 例如,sheet1将等于其单元格A1的值,并且sheet2也将等于其单元格A1的值。 请在 工作表 框,然后选择 重命名具有特定单元格的工作表 选项,然后在框中指定单元格A1。

3.表格名称不会随着单元格值的更改而自动更改。

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。


使用 Kutools for Excel 使工作表选项卡名称等于单元格值

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 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