gpt4 book ai didi

vba - 如何格式化合并单元格周围的边框vba

转载 作者:行者123 更新时间:2023-12-02 09:42:45 25 4
gpt4 key购买 nike

所以我有一个如下所示的合并单元格

enter image description here

以下是我在其周围放置边框的代码:

 Dim c As Range

For Each c In testing
If c.MergeCells Then
c.Interior.ColorIndex = 19
c.Borders.LineStyle = xlContinuous
c.Borders.Weight = xlThick
c.Borders.Color = vbGreen
End If
Next

此代码仅在左上角单元格周围创建边框(见图)。如何确保边框位于整个合并单元格周围?

最佳答案

您必须使用引用范围的MergeArea

Dim c As Range

For Each c In testing
If c.MergeCells Then
With c.MergeArea
.Interior.ColorIndex = 19
.Borders.LineStyle = xlContinuous
.Borders.Weight = xlThick
.Borders.Color = vbGreen
End With
End If
Next

关于vba - 如何格式化合并单元格周围的边框vba,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38941039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com