Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBComponent refer to sheet by tab name

Tags:

excel

vba

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?

like image 913
Ninja Dude Avatar asked Oct 15 '25 07:10

Ninja Dude


1 Answers

You can use

Set VBComp = VBProj.VBComponents(Worksheets("SummaryTab").CodeName)
like image 147
YowE3K Avatar answered Oct 18 '25 00:10

YowE3K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!