▷ 如何通过VBA隐藏/显示列/行?

您所在的位置:网站首页 excel快速隐藏不连续行 ▷ 如何通过VBA隐藏/显示列/行?

▷ 如何通过VBA隐藏/显示列/行?

2024-07-01 08:22| 来源: 网络整理| 查看: 265

VBA隐藏属性

要使用 VBA 隐藏/显示 Excel 中的列或行,可以使用“隐藏”属性。要使用此属性,必须使用范围对象指定列或行,然后指定 TRUE/FALSE。

使用范围对象指定列或行。之后,使用整个列/行属性来引用整个行或列。然后使用隐藏属性。最后,指定真/假。

这是要考虑的示例:

VBA-隐藏属性 Sub vba_hide_row_columns() 'hide the column A Range("A:A").EntireColumn.Hidden = True 'hide the row 1 Range("1:1").EntireRow.Hidden = True End Sub

在上面的代码中,我们使用隐藏属性来隐藏 A 列和 1 行。下面是显示它们的代码。

Sub vba_hide_row_columns() 'unhide the column A Range("A:A").EntireColumn.Hidden = False 'unhide the row 1 Range("1:1").EntireRow.Hidden = False End Sub隐藏/显示多行和多列VBA Sub vba_hide_row_columns() 'hide the column A to c Range("A:C").EntireColumn.Hidden = True 'hide the row 1 to 4 Range("1:4").EntireRow.Hidden = True End Sub

同样,如果你想显示多行和多列。

Sub vba_hide_row_columns() 'hide the column A to c Range("A:C").EntireColumn.Hidden = False 'hide the row 1 to 4 Range("1:4").EntireRow.Hidden = False End Sub隐藏所有列和行 Sub vba_hide_row_columns() 'hide the column A Columns.EntireColumn.Hidden = True 'hide the row 1 Rows.EntireRow.Hidden = True End Sub隐藏所有列和行显示所有列和行 Sub vba_hide_row_columns() 'unhide all the columns Columns.EntireColumn.Hidden = False 'unhide all the rows Rows.EntireRow.Hidden = False End Sub隐藏/显示另一个工作表中的列和行 Sub vba_hide_row_columns() 'hide all columns in the sheet 1 Worksheets("Sheet1").Columns.EntireColumn.Hidden = False 'hide all rows in the sheet 1 Worksheets("Sheet1").Rows.EntireRow.Hidden = False End Sub什么是VBA相关教程在 Excel 中使用 VBA 计算行数Excel VBA 字体(颜色、大小、类型和粗体) Excel VBA 范围 – 使用范围和单元格在 Excel 中使用 VBA 将边框应用于单元格在 Excel 中使用 VBA 查找最后一行、最后一列和单元格


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3