|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 lt0314 于 2012-9-11 20:26 编辑
- Sub twopages()
- Dim a(), fcell As Range, r1 As Range, r2 As Range
- ActiveWindow.View = xlPageBreakPreview
- m = ActiveSheet.HPageBreaks.Count
- If m > 0 Then
- ReDim a(1 To m + 1, 1 To 2)
- sss = WorksheetFunction.Transpose(Range("print_area"))
- parea = Split(Range("print_area").Address, ":")
- nnn = UBound(sss) - 1
- Set fcell = Range(parea(0))
- For i = 1 To m
- a(i, 1) = fcell.Address
- Set fcell = ActiveSheet.HPageBreaks(i).Location
- a(i, 2) = fcell.Offset(-1, nnn).Address
- Next i
- a(i, 1) = fcell.Address
- a(i, 2) = parea(1)
- isodd = m + 1 Mod 2
- Set r1 = Range(a(1, 1), a(1, 2))
- If m > 1 Then Set r2 = Range(a(2, 1), a(2, 2))
- On Error Resume Next
- For i = 3 To m + 1 Step 2
- Set r1 = Union(r1, Range(a(i, 1), a(i, 2)))
- Set r2 = Union(Range(a(i + 1, 1), a(i + 1, 2)), r2)
- Next i
- End If
- If isodd Then Set r2 = Union([iv65536], r2)
- r1.PrintPreview
- MsgBox "换页"
- r2.PrintPreview
- End Sub
- 是excel的
复制代码 |
|