|
本帖最后由 乐乐2006201506 于 2016-5-7 23:52 编辑
麻烦哪位老师帮帮忙(前几天自己录制的宏代码有些长,不过自己终于简化到这个程度了),希望还能简化。
谢绝灌水,谢绝说风凉话!请理解,谢谢!
Sub 工资表设置07版简化()
Range("A1").Select
Sheets("Sheet1").Select
Sheets("Sheet1").Copy
Range("A:B,E:E,H:J,P:P,W:W,Z:Z,AB:AB,AF:AH,AL:AL,AO:AO").Select
Selection.Delete
Range("AO1").Activate
Range("A1:Z1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Borders.Weight = 2
End With
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "序号"
Range("A2").Select
Range("A2") = "1"
Range("A3") = "2"
Range("A2:A3").Select
Selection.AutoFill Destination:=Range("A2:A244")
Range("A2:A244").Select
Columns("B:B").Select
Selection.Copy
Columns("A:A").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Columns("A:AA").AutoFit
Range("A1").Select
[S:S].ColumnWidth = 11.38
Application.CutCopyMode = False
With Range("A2:AA244")
.Borders.Weight = 2
.RowHeight = 22.5
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With Range("A1:AA1") '这个"A1:AA1"和下一个with中的"A1:AA1"形式一样,但实际行数不同,因为插入了一行。
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Range("A1:AA1")
.RowHeight = 42.75
.Merge
.Font.Name = "黑体"
.Font.Size = 26
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Value = "表"
End With
With Range("A2:AA2")
.RowHeight = 36
End With
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$2"
.PrintArea = "A1:AA245"
.CenterFooter = "第 &P 页,共 &N 页"
.LeftMargin = Application.InchesToPoints(0.551181102362205)
.RightMargin = Application.InchesToPoints(0.551181102362205)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0.78740157480315)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 71
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
MsgBox "表设置完成"
End Sub
Option Explicit
Sub 工资表设置07版简化()
Sheets("Sheet1").Select
Range("A:B,E:E,H:J,P:P,W:W,Z:Z,AB:AB,AF:AH,AL:AL,AO:AO").Delete
With Range("A1:Z1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Borders.Weight = 2
End With
Columns("A:A").Insert
Range("A1") = "序号"
Range("A2") = 1
Range("A2").AutoFill Destination:=Range("A2:A224"), Type:=xlFillSeries
Columns("B:B").Copy
Columns("A:A").PasteSpecial Paste:=xlPasteFormats
Columns("A:AA").AutoFit
[S:S].ColumnWidth = 11.38
With Range("A2:AA244")
.Borders.Weight = 2
.RowHeight = 22.5
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
Range("A1:AA1").Insert
With Range("A1:AA1")
.RowHeight = 42.75
.Merge
.Font.Name = "黑体"
.Font.Size = 26
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Value = "表"
End With
Range("A2:AA2").RowHeight = 36
'页面设置:纸张为A3,横向,缩放比例为72%;页边距为上下均为2,左右均为1.4,同时设置打印时纸张内容水平居中;页脚为第一页共几页格式;表头为第一二行。
'注释一句或几句,没问题就继续注释,有问题就取消看帮助。
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$2" '保留
.PrintArea = "A1:AA245"
.CenterFooter = "第 &P 页,共 &N 页"
.LeftMargin = Application.InchesToPoints(0.551181102362205)
.RightMargin = Application.InchesToPoints(0.551181102362205)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0.78740157480315)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA3 '保留
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 71
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
Application.CutCopyMode = False
MsgBox "表设置完成"
End Sub
|
|