如果活动工作表代码名称等于则退出子

时间:2016-10-21 19:44:58

标签: excel excel-vba vba

为什么这段代码缩短为1行,Code有效,但想整合它。

'If active sheet has the code name below then exit this sub

If ActiveSheet.CodeName = "VPL" Then Exit Sub
If ActiveSheet.CodeName = "VBA_BlankBidSheet" Then Exit Sub
If ActiveSheet.CodeName = "VBA_BlankOptionSheet" Then Exit Sub
If ActiveSheet.CodeName = "VBA_Dropdowns" Then Exit Sub

1 个答案:

答案 0 :(得分:1)

我真的不明白你的问题......

你的意思是喜欢使用Or?

If ActiveSheet.CodeName = "VPL" Or ActiveSheet.CodeName = "VBA_BlankBidSheet" Or ActiveSheet.CodeName = "VBA_BlankOptionSheet" Or ActiveSheet.CodeName = "VBA_Dropdowns" Then Exit Sub