单元格设边框
Range("C3:E6").Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = True End With 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 Selection.Borders(xlInsideVertical).LineStyle = xlNone Selection.Borders(xlInsideHorizontal).LineStyle = xlNone ----------------------------------------------------------- 然后就是找出其中需要的代码,并进行修改。 假设我定义了一个xlsSheet对象,那么代码可以修改如下: xlsSheet.Range("C3:E6").MergeCells = True '//合并单元格 '//下面是设置边框 With xlsSheet.Range("C3:E6").Borders(7) 'xlEdgeLeft .LineStyle = 1 'xlContinuous .Weight = 2 'xlThin .ColorIndex = -4105 'xlAutomatic End With With xlsSheet.Range("C3:E6").Borders(8) 'xlEdgeTop .LineStyle = 1 .Weight = 2 .ColorIndex = -4105 End With With xlsSheet.Range("C3:E6").Borders(9) 'xlEdgeBottom .LineStyle = 1 .Weight = 2 .ColorIndex = -4105 End With With xlsSheet.Range("C3:E6").Borders(10) 'xlEdgeRight .LineStyle = 1 .Weight = 2 .ColorIndex = -4105 End With |