Excel VBA隐藏名称在数组中的工作表 [英] Excel VBA hide sheets with names in array

查看:61
本文介绍了Excel VBA隐藏名称在数组中的工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要隐藏名称为"ABC","DEF","GHI"

这是我的代码:

Sub hideSheets()
Dim ws As Worksheet
invisible = Array("ABC", "DEF", "GHI")

For Each ws In ActiveWorkbook.Worksheets
    For Each nome In invisible
        If ws.Name = nome Then
            ws.Visible = False
        Else
            ws.Visible = True
        End If
    Next nome

Next ws

End Sub

没有隐藏任何工作表.

推荐答案

要隐藏 invisible 数组中的工作表,就这么简单:

To hide the sheets in your invisible array, it is as simple as this:

Sheets(invisible).Visible = False

注意:这非常适合隐藏.要使图纸再次可见,必须将每张图纸一一设置为可见.您不能像隐藏一样在一行中使用数组.

Note: this works well for hiding. To make the sheets visible again, you must set each sheet visible one by one; you cannot use the array in one line like you can for hiding.

这篇关于Excel VBA隐藏名称在数组中的工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆