乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>VBA</em> <em>excel</em> 如何自动获取当前

<em>VBA</em> <em>excel</em> 如何自动获取当前

作者:乔山办公网日期:

返回目录:excel表格制作


用工作表事件,当AAA或者BBB被激活时,就操作CCC
sub ()
dim currentsheet as worksheet
set currentsheet=activesheet

if currentsheet.name="AAA" or currentsheet.name="BBB" then
worksheets("CCC").range("B2").value="xxx"

worksheets("CCC").range("B2").interior.color=65535

end if

end sub

dim fname as string
fname=thisworkbook.name

即可得到当前工作簿的名字。
获得当前工作表的名字。
fname=activesheet.name
iRows=activesheet.usedrange.rows.count
iColumns=activesheet.usedrange.Columns.count

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

当前是activesheet吗?
代码工作簿是thisworkbook

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网