本文介绍了使用名称包含特定单词的VBA取消隐藏工作表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用下面的代码,在其中我可以选择所有包含单词"ba"的工作表,但是,如果这些工作表/选项卡被隐藏,我将无法获得运行时错误'1004"':"警告.
Using the code below where I'm able to select all sheets that contains the word "ba" on it however, if those sheets/tabs are hidden, I can't, I get a "Run-time errror '1004':" warning.
任何建议如何使此代码与隐藏的工作表/标签一起使用?因此,即使隐藏,它也会显示所有带有"ba"的工作表/标签名称?如果它们是隐藏的,我希望它们出现或.Visible = True
Any suggestion how could I make this code work with hidden sheet/tabs? So it shows all sheets/tabs names with "ba" even if it's hidden shows up? If they are hidden, I want them to appear or .Visible = True
Sub listray()
Dim ws As Worksheet, flg As Boolean
For Each ws In Sheets
If LCase(ws.Name) Like "*ba*" Then
ws.Select Not flg
flg = True
End If
Next
End Sub
End Sub
推荐答案
必须可见表格才能被选择.
The sheets have to be visible to be selected.
If LCase(ws.Name) Like "*ba*" Then
ws.Visible = xlSheetVisible
ws.Select Not flg
flg = True
End If
这篇关于使用名称包含特定单词的VBA取消隐藏工作表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!