ActiveSheet.Columns(iColumn).Hidden = True MsgBox \取消隐藏\
ActiveSheet.Columns(iColumn).Hidden = False End Sub
[示例04-11-03]插入行 Sub InsertRow() Dim rRow As Long
MsgBox \在当前单元格上方插入一行\ rRow = Selection.Row
ActiveSheet.Rows(rRow).Insert End Sub
[示例04-11-04]插入列 Sub InsertColumn() Dim cColumn As Long
MsgBox \在当前单元格所在行的左边插入一行\ cColumn = Selection.Column
ActiveSheet.Columns(cColumn).Insert End Sub
[示例04-11-05]插入多行 Sub InsertManyRow()
MsgBox \在当前单元格所在行上方插入三行\ Dim rRow As Long, i As Long For i = 1 To 3
rRow = Selection.Row
ActiveSheet.Rows(rRow).Insert Next i End Sub
[示例04-11-06]设置行高 Sub SetRowHeight()
MsgBox \将当前单元格所在的行高设置为25\ Dim rRow As Long, iRow As Long rRow = ActiveCell.Row
iRow = ActiveSheet.Rows(rRow).RowHeight ActiveSheet.Rows(rRow).RowHeight = 25 MsgBox \恢复到原来的行高\
ActiveSheet.Rows(rRow).RowHeight = iRow End Sub
[示例04-11-07]设置列宽 Sub SetColumnWidth()
MsgBox \将当前单元格所在列的列宽设置为20\
49
Dim cColumn As Long, iColumn As Long cColumn = ActiveCell.Column
iColumn = ActiveSheet.Columns(cColumn).ColumnWidth ActiveSheet.Columns(cColumn).ColumnWidth = 20 MsgBox \恢复至原来的列宽\
ActiveSheet.Columns(cColumn).ColumnWidth = iColumn End Sub
[示例04-11-08]恢复行高列宽至标准值 Sub ReSetRowHeightAndColumnWidth()
MsgBox \将当前单元格所在的行高和列宽恢复为标准值\ Selection.UseStandardHeight = True Selection.UseStandardWidth = True End Sub
[示例04-12]工作表标签
[示例04-12-01] 设置工作表标签的颜色 Sub SetSheetTabColor()
MsgBox \设置当前工作表标签的颜色\ ActiveSheet.Tab.ColorIndex = 7 End Sub
[示例04-12-01]恢复工作表标签颜色 Sub SetSheetTabColorDefault()
MsgBox \将当前工作表标签颜色设置为默认值\ ActiveSheet.Tab.ColorIndex = -4142 End Sub
[示例04-12-03]交替隐藏或显示工作表标签 Sub HideOrShowSheetTab()
MsgBox \隐藏/显示工作表标签\
ActiveWindow.DisplayWorkbookTabs = Not ActiveWindow.DisplayWorkbookTabs End Sub
[示例04-13]确定打印的页数(HPageBreaks属性与VPageBreaks属性) Sub PageCount() Dim i As Long
i = (ActiveSheet.HPageBreaks.Count + 1) * (ActiveSheet.VPageBreaks.Count + 1)
MsgBox \当前工作表共\页.\End Sub
[示例04-14]保护/撤销保护工作表
50