作者:乔山办公网日期:
返回目录:excel表格制作
比如你要给A1:B11单元格加边框,可以使用以下代码Range("A1:B11").Borders.LineStyle=1
取消边框线 Range("A1:B11").Borders.LineStyle=0
Sub 边框()
Range("a1").BorderAround ColorIndex:=3, Weight:=xlThin '红色、细线
End Sub
下面是vba的代码,要不你参考一下?636f7079e79fa5e98193335
Sub Macro2()
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
Private Sub CommandButton1_Click()
Dim I, L,J, M
Set SH1 = Sheet1
On Error GoTo QQ
M = InputBox("输入行数!抄")
If M = "" Then Exit Sub
With SH1
L = .[A1000].End(xlUp).Row
For I = 1 To M
.Cells(I + L, 1) = .Cells(L, 1) + I
For J = 1 To 5
.Cells(I + L, J).BorderAround ColorIndex:=3, Weight:=xlThin '红色、细线zd
Next
Next
End With
QQ:
End Sub