通过索引表隐藏空工作表问题

weixin_40984619 2017-11-24 10:35:29
我是菜鸟,请教大虾,我有如下图的一个索引表的工作簿

通过如下代码隐藏空工作表不成,提示错误。

Sub YCKB() '隐藏空表
Application.ScreenUpdating = False
ThisWorkbook.Unprotect

Dim Parr
Dim Ccount As Integer
Dim Ix As Integer
Dim Ax As Integer
Dim ash As String
Parr = Array(1, 5)
Ccount = Sheets("索引").Range("C65536").End(xlUp).Row

For Ax = 1 To UBound(Parr)
For Ix = 1 To Ccount
If Sheets("索引").Cells(Ix, Parr(Ax)) <> "√" And Len(Sheets("索引").Cells(Ix, Parr(Ax) + 2)) > 0 And WorksheetFunction.IsNumber(Sheets("索引").Cells(Ix, Parr(Ax) + 2)) = False Then
ash = Sheets("索引").Cells(Ix, Parr(Ax) + 2)
If Sheets(ash).Visible = True Then
Sheets(ash).Visible = False
End If
End If
Next Ix
Next Ax
Application.ScreenUpdating = True
ThisWorkbook.Protect STRUCTURE:=True, Windows:=False
End Sub

提示错误为下标越界。调试指向这里有错误: If Sheets(ash).Visible = True Then。
请大虾指点
...全文
471 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧