Reputation: 1392
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents("Sheet10")
I have the code above. Currently Sheet10 is named as SummaryTab in the excel tab. I want to refer to the VBComponent using the name in the excel tab. Meaning that I want to use something like
Set VBComp = VBProj.VBComponents("SummaryTab")
However, the above code is giving me errors. how can I fix this?
Upvotes: 4
Views: 2841
Reputation: 23984
You can use
Set VBComp = VBProj.VBComponents(Worksheets("SummaryTab").CodeName)
Upvotes: 7