|
建议将设置边框的18句代码改成如下:
.Borders.LineStyle = xlContinuous '设置整体边框的框线类型
.Borders.ColorIndex = xlAutomatic '设置整体边框的颜色
.BorderAround Weight:=xlMedium '设置外围边框的粗细
先用Borders设置全体边框,然后用BorderAround设置外围边框。
测试:
Public Sub CreateSalarySheet()
Dim LastRow As Long, TempRow As Long
Dim LastColumn As Integer
On Error Resume Next
Dim sh As Worksheet, arr
Set sh = Sheets("工资条")
If Err.Number = 9 Then '可以利用下标越界错误捕获来判断“工资条”这个工作表是否存在
Set sh = Sheets.Add(after:=Worksheets("工资表"))
sh.Name = "工资条"
End If
sh.Cells.Clear '先清除所有内容
With Worksheets("工资表") '先确定区域工资表行列区域
LastRow = .[a65536].End(xlUp).Row
LastColumn = .[iv1].End(xlToLeft).Column
arr = .Range(.[a1], .Cells(LastRow, LastColumn)).Value
End With
Dim i As Long, m As Integer, brr()
ReDim brr(1 To 3 * LastRow - 3, 1 To LastColumn)
sh.Columns(1 & ":" & LastColumn).ColumnWidth = 10.63
For i = 2 To LastRow
For m = 1 To LastColumn
brr(i * 3 - 5, m) = arr(1, m)
brr(i * 3 - 4, m) = arr(i, m)
Next
With sh.Range(Cells(i * 3 - 5, 1), Cells(i * 3 - 4, LastColumn))
.Borders.LineStyle = xlContinuous '设置整体边框的框线类型
.Borders.ColorIndex = xlAutomatic '设置整体边框的颜色
.BorderAround Weight:=xlMedium '设置外围边框的粗细
End With
Next
sh.[a1].Resize(LastRow * 3 - 3, LastColumn) = brr
End Sub
[ 本帖最后由 unsamesky 于 2010-11-21 22:44 编辑 ] |
|