|
如何写VBA代码,实现对选择区域里的所有单元格进行判断,设置所有的有内容的右边单元格的格式为凹边框。
现在我只能选择D8,F8,H8,D10,F10,H10然后分别点击按钮设置边框格式
需要做成,选择C8:H10范围。遍历所有单元格,对于有文字的单元格的右一单元格设置凹边框格式。
一次选定,一次性设置。
设置凹边框代码为
Sub 矩形1_Click()
Application.ScreenUpdating = False
Selection.Borders(xlEdgeLeft).Color = RGB(128, 128, 128)
Selection.Borders(xlEdgeLeft).Weight = xlMedium
Selection.Borders(xlEdgeTop).Color = RGB(128, 128, 128)
Selection.Borders(xlEdgeTop).Weight = xlMedium
Selection.Borders(xlEdgeRight).Color = RGB(217, 217, 217)
Selection.Borders(xlEdgeRight).Weight = xlMedium
Selection.Borders(xlEdgeBottom).Color = RGB(217, 217, 217)
Selection.Borders(xlEdgeBottom).Weight = xlMedium
Selection.Interior.Color = RGB(255, 255, 255)
Application.ScreenUpdating = True
End Sub
|
|