fkjj.net
当前位置:首页 >> VBA ExCEl如何自动获取当前工作表的名字? >>

VBA ExCEl如何自动获取当前工作表的名字?

dim fname as string fname=thisworkbook.name 即可得到当前工作簿的名字。 获得当前工作表的名字。 fname=activesheet.name

Sub ExcelVersion() verarr = Array("8.0", "9.0", "10.0", "11.0", "12.0", "14.0") vername = Array("97", "2000", "2002", "2003", "2007", "2010") For i = 1 To 6 If verarr(i - 1) = Application.Version Then MsgBox "当前Excel版本为:E...

获取指定的工作簿中工作表名称而非本工作簿中表的名称,下面的代码可以使用: Sub 提取name() Dim wk As Workbook Dim sh As Worksheet Dim rw As Byte Set wk = Workbooks.Open("D:\函数习题\第1章 函数基础.xls") For Each sh In Workbooks(2)...

针对ThisWorkbook对象的BeforeClose事件添加如下代码 Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim fileStr As String fileStr = "$111.xls$333.xls$“ ‘头尾都用$分隔,循环判断文件名 For I = Workbooks.count To 1 Step -1 If In...

Sub addas() Sheets.Add after:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = Year(Now()) & "-" & Month(Now()) & "-" & Day(Now()) End Sub

sub test() worksheets("Sheet1").[a1]=thisworkbook.name end sub

可以利用VBA sub m for each sh in sheets k=k+1 cells(k,1)=sh.name next end sub 这样,所有工作表名就放到A列里了

iRows=activesheet.usedrange.rows.count iColumns=activesheet.usedrange.Columns.count '如果表格前面的几行或几列可能是空的,需要获得最下面的行数和最右面的列数: with activesheet.usedrange iEndRow=.rows.count+.row-1 iEndColumn=.Col...

只找出一个工作簿还是全部找出来?

[名称].Address 当然,你还可以有address的参数。

网站首页 | 网站地图
All rights reserved Powered by www.fkjj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com