VBA Excel 单元格操作

1. 设置单元格边框:

.Range("A3:M" & l + 1).Select
With Selection.Borders()
  .LineStyle = xlContinuous
  .ColorIndex = 0
  .TintAndShade = 0
  .Weight = xlHairline'实线
End With

.Range("I3:M" & l + 1).Borders(xlEdgeLeft).Weight = xlThin'细实线
.Range("I3:M" & l + 1).Borders(xlEdgeTop).Weight = xlThin
.Range("I3:M" & l + 1).Borders(xlEdgeBottom).Weight = xlThin
.Range("I3:M" & l + 1).Borders(xlEdgeRight).Weight = xlThin

'若 产品不同,则“粗线”
For i = 5 To l
  If .Cells(i, 6).Value <> .Cells(i - 1, 6).Value Then
    .Range("A" & i & ":P" & i).Borders(xlEdgeTop).Weight = xlThin
  End If
Next i


 

 

posted @ 2014-06-21 14:37  ssfie  阅读(419)  评论(0编辑  收藏  举报