想通过VBA来隐藏显示工作表中的行列,请参阅如下的代码:
①隐藏、显示行的VBA代码
Sub HideMyRow()
Dim iRow As Long
MsgBox "隐藏当前单元格所在的行"
iRow = ActiveCell.Row
ActiveSheet.Rows(iRow).Hidden = True
MsgBox "取消隐藏"
ActiveSheet.Rows(iRow).Hidden = False
End Sub
②隐藏、显示列的VBA代码
Sub HideColumn()
Dim iColumn As Long
MsgBox "隐藏当前单元格所在列"
iColumn = ActiveCell.Column
ActiveSheet.Columns(iColumn).Hidden = True
MsgBox "取消隐藏"
ActiveSheet.Columns(iColumn).Hidden = False
End Sub