空格检查前一页,并在Excel中插入行
(A795:O830)中有一段文字。 它通过分页符与其他页面分开,始终是打印(xls,pdf)文档的最后一页。 有时在第一页上有很多可用空间,并且(A795:O830)可能在那里安装。 现在它由分页符完成,不可更改。 在我的情况下,66行可以放在一个页面上。
是否有任何macros可以自动检查前一页是否有足够的空白空间(A795:O830)并将其插入?
这是我目前的macros:
Sub Remove_color() Dim myRange As Range Dim cell As Range Set myRange = Range("A24:O785") For Each cell In myRange myRange.Interior.ColorIndex = 0 Next End Sub Sub Hide_empty_cells() Set rr = Range("A24:N832") For Each cell In rr cell.Select If cell.HasFormula = True And cell.Value = "" And cell.EntireRow.Hidden = False Then Rows(cell.Row).EntireRow.Hidden = True Next cell End Sub Sub Save_excel() Dim iFileName$, iRow&, iCol&, iCell As Range, iArr iFileName = ThisWorkbook.Path & "\New_folder_" & [D5] & "_" & ".xls" iArr = Array(1, 3, 4): iCol = UBound(iArr) + 1 Application.ScreenUpdating = False Application.DisplayAlerts = False Application.Calculation = xlManual ThisWorkbook.Sheets(2).Copy With ActiveWorkbook.ActiveSheet .Buttons.Delete '.Shapes("Button 1").Delete .UsedRange.Value = .UsedRange.Value .SaveAs iFileName, xlExcel8: .Parent.Close End With Application.Calculation = xlAutomatic Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub Sub Save_pdf() ActiveWorkbook.Sheets(2).Select ActiveSheet.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=ThisWorkbook.Path & "\New_folder_\" & [D5] & "_" & ".pdf", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=No, _ OpenAfterPublish:=False End Sub Sub doitallplease() Call Remove_color Call Hide_empty_cells Call Save_excel Call Save_pdf End Sub