作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下代码在我的工作簿中的所有工作表上执行宏,但 excludesheets 字符串中的工作表除外。
奇怪的是,它也忽略了其他工作表,背后没有逻辑。
主页、概述和设置在最前面,然后我有 18 张要执行的工作表,然后是原始、指标、旧概述和最终排除的团队。
所有的弦乐表都被跳过了,但我想要的 9 张也被跳过了。
任何人都可以帮忙吗?
Sub Error_Check()
Const excludeSheets As String = "Home Page,Overview,Setup,Original,Metrics,Overview old,Teams"
Dim ws As Worksheet
For Each ws In Sheets
ws.Activate
If IsError(Application.Match(ws.Name, Split(excludeSheets, ","))) Then
'Macro bit
End If
Next ws
End Sub
最佳答案
我认为你的 Match
语句需要有 match_type
指定的参数,因为您将其留空。
试试这个(注意 0):
If IsError(Application.Match(ws.Name, Split(excludeSheets, ","),0)) Then
例如,此参数指定精确值是否匹配或最大。从 MS 文档中查看:
If match_type is 1, MATCH finds the largest value that is less than or equal to lookup_value.
If match_type is 0, MATCH finds the first value that is exactly equal to lookup_value. Lookup_array can be in any order.
If match_type is -1, MATCH finds the smallest value that is greater than or equal to lookup_value.
If match_type is omitted, it is assumed to be 1.
关于vba - 不寻常的循环宏行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25786095/
我是一名优秀的程序员,十分优秀!