日记首页
|
列表
|
添加日记
|
管理登陆
标题:vba自动生成表格
<div title="点击运行该代码!" class="HtmlCode" style="cursor: pointer;" onclick="preWin=window.open('','','');preWin.document.open();preWin.document.write(this.innerText);preWin.document.close();" ;="">Sub 自动生成表格()<br> Rem 设置单元格内字体、颜色、大小<br> Dim rng As Range<br> Y = ActiveCell.SpecialCells(xlLastCell).address<br> With Range("A1:" & Y).Font<br> .Name = "黑体"<br> .FontStyle = "Bold"<br> .Size = 24<br> End With<br> With Range("A2:" & Y).Font<br> .Name = "仿宋_GB2312"<br> .Size = 12<br> .Underline = 2<br> End With<br> With Range("A3:" & Y).Font<br> .Name = "仿宋_GB2312"<br> .Size = 10<br> End With<br> Rem 设置行高、列宽<br> With Range("A1")<br> .RowHeight = Application.CentimetersToPoints(1.2)<br> .ColumnWidth = Application.CentimetersToPoints(0.5)<br> End With<br> With Range("A2")<br> .RowHeight = Application.CentimetersToPoints(1)<br> End With<br> With Range("A3")<br> .RowHeight = Application.CentimetersToPoints(0.6)<br> End With<br> Rem 画边框<br> Set rng = Range("a3:" & Y)<br> With rng.Borders<br> .LineStyle = xlContinuous<br> .Weight = xlThin<br> .ColorIndex = 5<br> End With<br> rng.BorderAround xlContinuous, xlMedium, 5<br> Set rng = Nothing<br> <br>End Sub<br> </div>