gpt4 book ai didi

excel - 隐藏表格 vba

转载 作者:行者123 更新时间:2023-12-04 20:03:43 24 4
gpt4 key购买 nike

我需要能够隐藏除数组中的所有工作表之外的所有工作表。我已经为数组编写了代码,但现在剩下的都卡住了。

Sub ShowHideWorksheets()
arr = Array("Readme", "Compliance cert", "Cash Balances", "Occupancy Report", "ALPH", "BC", "Bish",
"GC", "HS", "STB", "WOL", "GroupCo", "OpCos", "RCG_ALL")

For Each Value In arr


Next Value
End Sub
任何帮助将不胜感激。

最佳答案

隐藏工作表

Option Explicit

Sub hideWorksheets()

Dim arr As Variant
arr = Array("Readme", "Compliance cert", "Cash Balances", _
"Occupancy Report", "ALPH", "BC", "Bish", "GC", "HS", "STB", _
"WOL", "GroupCo", "OpCos", "RCG_ALL")

Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet

For Each ws In wb.Worksheets
If IsError(Application.Match(ws.Name, arr, 0)) Then
ws.Visible = xlSheetHidden
End If
Next ws

End Sub

Sub showAllWorksheets()

Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet

For Each ws In wb.Worksheets
If ws.Visible = xlSheetHidden Then ws.Visible = xlSheetVisible
Next ws

End Sub

关于excel - 隐藏表格 vba,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63085145/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com