【发布时间】:2015-02-11 15:54:34
【问题描述】:
所以这是我的问题: 我有一个模板表,其中粘贴了数据。数据行的数量总是不同的(我认为它永远不会高于 30,但我编码的容量为 103) 数据粘贴完成后,sub 应该相应地设置打印区域和边框,但不是到最后一行数据,而是到包含数据的最后一页。我写了这个丑陋,它似乎工作。我确实想知道是否有一种方法可以在不嵌套 IF 语句的情况下执行此操作(对于更大的数据集,我将不得不重新执行此操作)
parow = wsp.Range("A" & Rows.Count).End(xlUp).row
If parow <= 15 Then
parow = 15
Else:
If parow <= 29 Then
parow = 29
Else
If parow <= 43 Then
parow = 43
Else
If parow <= 58 Then
parow = 58
Else
If parow <= 73 Then
parow = 73
Else
If parow <= 88 Then
parow = 88
Else
If parow <= 103 Then
parow = 103
Else
End If
End If
End If
End If
End If
End If
End If
With wsp.PageSetup
.PrintArea = "$A$1:$G" & parow
.PrintTitleRows = "$1:$1"
.Orientation = xlLandscape
.FitToPagesWide = 1
End With
【问题讨论】:
标签: vba if-statement printing