VBComponent指的是逐页选项卡名称

时间:2017-04-19 06:23:07

标签: vba excel-vba excel

Set VBProj = ActiveWorkbook.VBProject
        Set VBComp = VBProj.VBComponents("Sheet10")

我有上面的代码。目前,Sheet10在excel选项卡中被命名为SummaryTab。我想使用excel选项卡中的名称来引用VBComponent。这意味着我想使用像

这样的东西
Set VBComp = VBProj.VBComponents("SummaryTab")

但是,上面的代码给了我错误。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:4)

您可以使用

Set VBComp = VBProj.VBComponents(Worksheets("SummaryTab").CodeName)
相关问题