Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一些 VBA 代码,它将隐藏表中除选定行之外的所有行。所以在下图中,选择了 MSFT,我希望所有其他 ListRows 都隐藏起来。
你会怎么做?
如果您正在为您的表格使用列表,则以下内容应该有效:
Sub HideAllListRowsExceptTheActiveOne() ActiveCell.ListObject.DataBodyRange.Rows.Hidden = True ActiveCell.Rows.Hidden = False End Sub
您可以使用自定义按钮、上下文菜单项等来运行此子程序。