1

任何人都知道如何从该工作表上的 VBA 代码中获取工作表名称?即:sheet12上的代码将返回Sheet12的名称,sheet11上的相同代码将返回Sheet11的名称?谢谢。

4

2 回答 2

3

有两个属性可以参考:

  1. .Name:这是您可以在 Excel UI 中看到的工作表的名称
  2. .CodeName:这是您在 VB 编辑器中看到的工作表的名称

例子:

MsgBox "Name of the current sheet in Excel: " & ActiveSheet.Name & vbCrLf & _
    "Name of the sheet in VB editor: " & ActiveSheet.CodeName
于 2013-10-01T13:38:05.787 回答
2

这将给出激活的工作表的名称:

Sub dural()
    MsgBox ActiveSheet.Name
End Sub
于 2013-10-01T13:36:31.407 回答