Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1069|回复: 3

[已解决]批量添加工作表名称

[复制链接]
发表于 2022-2-14 22:20 | 显示全部楼层 |阅读模式
批量添加工作表名称.rar (15.01 KB, 下载次数: 8)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2022-2-15 08:00 | 显示全部楼层

Public Sub title()
Dim i As Integer
Dim CountSht As Integer

CountSht = Sheets.Count
For i = 1 To CountSht
Sheets(i).Activate
Columns(1).Select
Selection.Insert
Cells(1, 1).Value = "工作表名称"
Cells(2, 1).Value = ActiveSheet.Name
Next i

End Sub
回复

使用道具 举报

 楼主| 发表于 2022-2-15 10:42 | 显示全部楼层
Yunyun123 发表于 2022-2-15 08:00
Public Sub title()
Dim i As Integer
Dim CountSht As Integer

还有一点,我需要将工作表名添加至各表的每一行中,不仅第二行
回复

使用道具 举报

发表于 2022-2-15 10:54 | 显示全部楼层    本楼为最佳答案   
心灵有约 发表于 2022-2-15 10:42
还有一点,我需要将工作表名添加至各表的每一行中,不仅第二行

Public Sub title()
Dim i As Integer
Dim CountSht As Integer
Dim CountRow As Integer

CountSht = Sheets.Count
For i = 1 To CountSht
Sheets(i).Activate
CountRow = Cells(Rows.Count, 1).End(3).Row
Columns(1).Select
Selection.Insert
Cells(1, 1).Value = "工作表名称"
Range(Cells(2, 1), Cells(CountRow, 1)).Value = ActiveSheet.Name
Next i
End Sub


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-14 05:14 , Processed in 0.219865 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表