所以我有一个合并的单元格,如下所示
以下是我在其周围放置边框的代码:
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/