Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在vba中围绕不同范围更改边框和线型_Vba_Excel_Border - Fatal编程技术网

在vba中围绕不同范围更改边框和线型

在vba中围绕不同范围更改边框和线型,vba,excel,border,Vba,Excel,Border,[ 我试图在我的桌子周围画一个合适的边框,但每次我试图在基于颜色的特定范围内画边框时,它都会以虚线的形式出现。我想要实线,但我似乎对线条样式没有做任何修改。我也不想要红色框中的黑色垂直线,但这是唯一能使线条变为实线而不是虚线的方法我附上的第一张图片是我的,第二张是我想要的。下面是我一直在使用的代码: Sub borders() ' ' borders and colors ' ' 'B column = blue range("B2:B46, D2:D6").Select Sel

[

我试图在我的桌子周围画一个合适的边框,但每次我试图在基于颜色的特定范围内画边框时,它都会以虚线的形式出现。我想要实线,但我似乎对线条样式没有做任何修改。我也不想要红色框中的黑色垂直线,但这是唯一能使线条变为实线而不是虚线的方法我附上的第一张图片是我的,第二张是我想要的。下面是我一直在使用的代码:

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

也许试着打一个电话,所以

'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 Weight:=xlThin, LineStyle:= xlContinuous
   With Selection.Interior
    .Color = 11711154
    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 Weight:=xlThin, LineStyle:= xlContinuous
   With Selection.Interior
    .Color = 11711154
    End With

好的,谢谢!还有一个问题:关于如何让红线与灰色列重叠,使其黑色轮廓不显示在红色中,有什么想法吗?@beks123我认为最好的方法是删除左右边框
行(xlLeft/xlRight).Visible=False
适用于该范围内的所有单元格,但最末端的单元格除外。请在运行完所有内容后执行此操作(以确保在添加行之前不会删除行)好的,谢谢!还有一个问题:关于如何让红线与灰色列重叠,使其黑色轮廓不显示在红色中,有什么想法吗?@beks123我认为最好的方法是删除左右边框
行(xlLeft/xlRight).Visible=False
适用于该范围内的所有单元格,但最末端的单元格除外。请在运行完所有内容后执行此操作(以确保在添加行之前不会删除行)