VBA-联通话费明细单-格式调整
Sub ChangeColumn()
Rows(1).RowHeight = 24 '设置第1行的行高
Rows(1).WrapText = True '设置第1行的属性为“自动换行”
Rows(1).Font.Bold = False '设置第1行的字体为非粗体
Columns("A").ColumnWidth = 8 '以下是设置各列的列宽
Columns("B").ColumnWidth = 12
Columns("C").ColumnWidth = 26
Columns("D:E").ColumnWidth = 12
Columns("H").ColumnWidth = 4
Columns("J:K").ColumnWidth = 4
Columns("M").ColumnWidth = 4
Columns("N").ColumnWidth = 6
'设置页边距
With ActiveSheet.PageSetup '须开启Print Spoole服务
.LeftMargin = Application.InchesToPoints(0.5) '左边距
.RightMargin = Application.InchesToPoints(0.4) '右边距
.TopMargin = Application.InchesToPoints(0.35) '上边距
.BottomMargin = Application.InchesToPoints(0.35) '下边距
.HeaderMargin = Application.InchesToPoints(0) '页眉
.FooterMargin = Application.InchesToPoints(0) '页脚
End With
'加边框
ActiveSheet.UsedRange.Borders.LineStyle = xlContinuous '设置整体边框的框线类型
ActiveSheet.UsedRange.Borders.ColorIndex = xlAutomatic '设置整体边框的颜色
ActiveSheet.UsedRange.BorderAround Weight:=xlThin '设置外围边框的粗细
End Sub
'所有列宽自适应
'Sub AutocolsFit()
'Columns.EntireColumn.AutoFit
'End Sub
'或:假如工作表为Sheet1
'Sheet1.UsedRange.Rows.AutoFit '使用范围内的行自动匹配行高
'Sheet1.UsedRange.Columns.AutoFit '使用范围内的列自动匹配列宽