在Excel中用VBA代码固定为A4纸张大小,不管增加或者删减内容纸张大小不变,并自动根据增加或删减内容调节列宽和行高

动态 未结 0 138
小小草
小小草 LV1 2023年9月23日 23:40 发表
Sub SetPrintArea() '设置打印区域为A4纸张大小 With ActiveSheet.PageSetup .PaperSize = xlPaperA4 .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 End With '调整列宽和行高 Cells.Select Selection.Columns.AutoFit Selection.Rows.AutoFit End Sub Private Sub Worksheet_Change(ByVal Target As Range) '内容发生变化时自动调整列宽和行高 Application.EnableEvents = False Target.EntireColumn.AutoFit Target.EntireRow.AutoFit Application.EnableEvents = True End Sub
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复