在vba中改变各种范围的边框和线条样式

时间:2016-06-21 14:24:04

标签: vba excel-vba border excel

my table now

[what I want my table to look like[2]

我试图在我的桌子周围找到一个合适的边框,但每当我尝试根据颜色在某些范围内制作它时,它就会以虚线显示出来。我想要实线,但我似乎没有做任何线条作品。我也不希望红色框内的黑色垂直线,但这是让线条变得坚固而不是虚线的唯一方法。我附上的第一张照片是我的样子,第二张是我想要的样子。这是我一直在使用的代码:

Sub borders()
'
' borders and colors
'

'
'B column = blue

   range("B2:B46, D2:D6").Select
   Selection.BorderAround
    With Selection.Interior

        .Color = 6108951

    End With

    'C column = gray

   range("C2:C6").Select
   With Selection.borders(xlLeft)
    .Weight = xlThin
   End With
   With Selection.borders(xlRight)
   .Weight = xlThin
   End With

   With Selection.Interior
    .Color = 12632256
    End With


   range("C7:C46").Select
   Selection.borders.LineStyle = xlContinuous
   With Selection.Interior
    .Color = 12632256
    End With

    'thin columns = gray
   range("E2:E46, I2:I46, M2:M46, Q2:Q46, U2:U46, Y2:Y46, AC2:AC46, AG2:AG46, AK2:AK46, AO2:AO46, AS2:AS46").Select
    Selection.BorderAround (xlThin)
   Selection.borders.LineStyle = xlContinuous
   With Selection.Interior
    .Color = 11711154
    End With

  'rows gray
    range("B21, B36, B43, B46").Select
    With Selection.Interior
    .Color = 12632256
   End With

'categories gray

range("D7:D45").Select
Selection.borders.LineStyle = xlContinuous

 With Selection.Interior
 .Color = 15395562
  End With

   'red rows
   range("C21:AS21, C36:AS36, C43:AS43, C46:AS46").Select
    Selection.BorderAround (xlThin)
   Selection.borders.LineStyle = xlContinuous
   'Selection.Border -Style: Solid
       With Selection.Interior
        .Color = 128
     End With


     'outside thick border

range("B2:AX46").Select
   Selection.BorderAround , Weight:=xlThick


   'border around trigger, weight, limit
   range("AU5:AW20").Select
    Selection.borders.LineStyle = xlContinuous

    range("AU5:AW6").Select
    Selection.borders.LineStyle = xlNone
    Selection.BorderAround (xlThin)




   End Sub

1 个答案:

答案 0 :(得分:1)

也许尝试全部打电话,所以

THREE.BufferGeometry