|
各位大神:为什么弹出“运行时错误1004,不能设置类Range 的Hidden属性”这样的问题框?代码写的有问题吗?感谢给与指正!
Sub 模式切换()
Application.ScreenUpdating = False
Dim sh As Worksheet
If ActiveSheet.OptionButton1.Value = True Then
ms = ActiveSheet.OptionButton1.Caption
ElseIf ActiveSheet.OptionButton2.Value = True Then
ms = ActiveSheet.OptionButton2.Caption
ElseIf ActiveSheet.OptionButton3.Value = True Then
ms = ActiveSheet.OptionButton3.Caption
End If
For Each sh In Sheets
If sh.Name = "资产评估结果分类汇总表(元)" Or sh.Name = "万元" Then
hh = 1
Else
hh = 2
End If '''大标题所在行的行号
If InStr(sh.Cells(hh, 1), "评估") > 0 Then '''判断工作表内的大标题是否包含 评估 二字
Y = sh.UsedRange.Columns.Count
lh = Replace(Cells(1, Y).Address(0, 0), "1", "")
sh.Columns("a:" & lh).EntireColumn.Hidden = False
If sh.Name = "资产评估结果分类汇总表(元)" Then
With sh
If ms = "设置申报表模式" Then
.Columns("d:h").EntireColumn.Hidden = True
ElseIf ms = "设置报告附表模式" Then
.Columns("d:e").EntireColumn.Hidden = True
.Range("F:F,G:G,H:H").ColumnWidth = 20
ElseIf ms = "设置底稿模式" Then
.Columns("a:" & lh).EntireColumn.Hidden = False
.Range("F:F,G:G,H:H").ColumnWidth = 20
End If
' 设置打印区域
.PageSetup.PrintArea = "$A$1:$H$61"
' 打印标题
.PageSetup.PrintTitleRows = "$1:$5"
' 页面设置
With sh.PageSetup
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.Zoom = 95
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintGridlines = False
.PrintHeadings = False
|
|